Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/dvx.Tests/ReportGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,16 @@ public void GenerateCsv_ContainsAllColumns()
Stage = 20,
Mode = 0,
ExecutionOrder = 5,
Description = "Some desc"
Description = "Some desc",
RunAsUser = Guid.Empty
}
};

var gen = new ReportGenerator();
var csv = gen.GenerateCsv(definitions);

csv.ShouldContain("Type,Entity,Message,Stage,Mode,ExecutionOrder,IsExplicit,Description");
csv.ShouldContain("MyPlugin,account,Create,PreOperation,Sync,5,True,Some desc");
csv.ShouldContain("Type,Entity,Message,Stage,Mode,ExecutionOrder,IsExplicit,Description,RunsAs");
csv.ShouldContain("MyPlugin,account,Create,PreOperation,Sync,5,True,Some desc,SYSTEM");
}

[Fact]
Expand Down
2 changes: 2 additions & 0 deletions src/dvx/Models/PluginStepDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
/// Any other Guid = impersonate that specific user.
/// </summary>
public Guid? RunAsUser { get; set; } = null;

public string RunAsUserString => (RunAsUser == null ? "Calling user" : RunAsUser == Guid.Empty ? "SYSTEM" : RunAsUser.ToString()) ?? "";

Check warning on line 30 in src/dvx/Models/PluginStepDefinition.cs

View workflow job for this annotation

GitHub Actions / build

Extract this nested ternary operation into an independent statement.

Check warning on line 30 in src/dvx/Models/PluginStepDefinition.cs

View workflow job for this annotation

GitHub Actions / build

Extract this nested ternary operation into an independent statement.

Check warning on line 30 in src/dvx/Models/PluginStepDefinition.cs

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested ternary operation into an independent statement.

See more on https://sonarcloud.io/project/issues?id=beyro_dvx-cli&issues=AZ-jB-Q28RVq03-P5nUh&open=AZ-jB-Q28RVq03-P5nUh&pullRequest=19
public string[] FilteringAttributes { get; set; } = Array.Empty<string>();

/// <summary>Unsecure config string (sdkmessageprocessingstep.configuration). null = not set.</summary>
Expand Down
12 changes: 7 additions & 5 deletions src/dvx/Services/ReportGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@
.ThenBy(d => d.ExecutionOrder)
.ToList();

var headers = new[] { "Stage", "Order", "Mode", "Plugin Type", "Description" };
var headers = new[] { "Stage", "Order", "Mode", "Plugin Type", "Description", "Runs as" };
var rows = PrepareTableRows(orderedSteps);

md.Table(headers, rows);
}

private List<string[]> PrepareTableRows(List<PluginStepDefinition> steps)

Check warning on line 76 in src/dvx/Services/ReportGenerator.cs

View workflow job for this annotation

GitHub Actions / build

Make 'PrepareTableRows' a static method.

Check warning on line 76 in src/dvx/Services/ReportGenerator.cs

View workflow job for this annotation

GitHub Actions / build

Make 'PrepareTableRows' a static method.
{
var rows = new List<string[]>();
int? lastStage = null;
Expand All @@ -84,7 +84,7 @@
if ((lastStage.HasValue && lastStage.Value != step.Stage) ||
(lastMode.HasValue && lastMode != step.Mode))
{
rows.Add(["", "", "", "", ""]); // Add blank row between stages/steps
rows.Add(["", "", "", "", "", ""]); // Add blank row between stages/steps
}

var order = step.IsExecutionOrderExplicit ? step.ExecutionOrder.ToString() : $"{step.ExecutionOrder}*";
Expand All @@ -95,7 +95,8 @@
order,
mode,
step.TypeFullName,
step.Description ?? "-"
step.Description ?? "-",
step.RunAsUserString
]);

lastStage = step.Stage;
Expand All @@ -105,10 +106,10 @@
return rows;
}

public string GenerateCsv(IEnumerable<PluginStepDefinition> definitions)

Check warning on line 109 in src/dvx/Services/ReportGenerator.cs

View workflow job for this annotation

GitHub Actions / build

Make 'GenerateCsv' a static method.

Check warning on line 109 in src/dvx/Services/ReportGenerator.cs

View workflow job for this annotation

GitHub Actions / build

Make 'GenerateCsv' a static method.
{
var sb = new StringBuilder();
sb.AppendLine("Type,Entity,Message,Stage,Mode,ExecutionOrder,IsExplicit,Description");
sb.AppendLine("Type,Entity,Message,Stage,Mode,ExecutionOrder,IsExplicit,Description,RunsAs");

foreach (var def in definitions.OrderBy(d => d.Entity).ThenBy(d => d.Message).ThenBy(d => d.Mode)
.ThenBy(d => d.ExecutionOrder))
Expand All @@ -122,7 +123,8 @@
def.Mode == 1 ? "Async" : "Sync",
def.ExecutionOrder.ToString(),
def.IsExecutionOrderExplicit.ToString(),
def.Description ?? ""
def.Description ?? "",
def.RunAsUserString
};
sb.AppendLine(string.Join(",", row.Select(EscapeCsv)));
}
Expand Down
6 changes: 3 additions & 3 deletions src/dvx/dvx.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<PackAsTool>true</PackAsTool>
<ToolCommandName>dvx</ToolCommandName>
<PackageId>dvx.cli</PackageId>
<Version>1.9.0</Version>
<Version>1.10.0</Version>
<Authors>Byron Matus</Authors>
<Description>CLI for deploying code-first Dataverse / Power Platform artifacts — plugin assemblies and web resources.</Description>
<LangVersion>default</LangVersion>
Expand All @@ -17,8 +17,8 @@
<RepositoryUrl>https://github.com/beyro/dvx-cli</RepositoryUrl>
<PackageIcon>package-icon.png</PackageIcon>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReleaseNotes>1.9.0:
- New `report` command to generate a report of plugin registrations in Markdown and CSV</PackageReleaseNotes>
<PackageReleaseNotes>1.10.0:
- Add column to `plugin report` output files that shows the user the plugin runs as</PackageReleaseNotes>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading