diff --git a/src/dvx.Tests/ReportGeneratorTests.cs b/src/dvx.Tests/ReportGeneratorTests.cs index e6a21b3..33c3ce3 100644 --- a/src/dvx.Tests/ReportGeneratorTests.cs +++ b/src/dvx.Tests/ReportGeneratorTests.cs @@ -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] diff --git a/src/dvx/Models/PluginStepDefinition.cs b/src/dvx/Models/PluginStepDefinition.cs index 56f1a2e..fc4b8ff 100644 --- a/src/dvx/Models/PluginStepDefinition.cs +++ b/src/dvx/Models/PluginStepDefinition.cs @@ -26,6 +26,8 @@ public int ExecutionOrder /// Any other Guid = impersonate that specific user. /// public Guid? RunAsUser { get; set; } = null; + + public string RunAsUserString => (RunAsUser == null ? "Calling user" : RunAsUser == Guid.Empty ? "SYSTEM" : RunAsUser.ToString()) ?? ""; public string[] FilteringAttributes { get; set; } = Array.Empty(); /// Unsecure config string (sdkmessageprocessingstep.configuration). null = not set. diff --git a/src/dvx/Services/ReportGenerator.cs b/src/dvx/Services/ReportGenerator.cs index 62d0cb6..76edb28 100644 --- a/src/dvx/Services/ReportGenerator.cs +++ b/src/dvx/Services/ReportGenerator.cs @@ -67,7 +67,7 @@ private void RenderStepTable(MarkdownBuilder md, IEnumerable 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); @@ -84,7 +84,7 @@ private List PrepareTableRows(List steps) 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}*"; @@ -95,7 +95,8 @@ private List PrepareTableRows(List steps) order, mode, step.TypeFullName, - step.Description ?? "-" + step.Description ?? "-", + step.RunAsUserString ]); lastStage = step.Stage; @@ -108,7 +109,7 @@ private List PrepareTableRows(List steps) public string GenerateCsv(IEnumerable definitions) { 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)) @@ -122,7 +123,8 @@ public string GenerateCsv(IEnumerable definitions) def.Mode == 1 ? "Async" : "Sync", def.ExecutionOrder.ToString(), def.IsExecutionOrderExplicit.ToString(), - def.Description ?? "" + def.Description ?? "", + def.RunAsUserString }; sb.AppendLine(string.Join(",", row.Select(EscapeCsv))); } diff --git a/src/dvx/dvx.csproj b/src/dvx/dvx.csproj index 83212c8..33aa2df 100644 --- a/src/dvx/dvx.csproj +++ b/src/dvx/dvx.csproj @@ -7,7 +7,7 @@ true dvx dvx.cli - 1.9.0 + 1.10.0 Byron Matus CLI for deploying code-first Dataverse / Power Platform artifacts — plugin assemblies and web resources. default @@ -17,8 +17,8 @@ https://github.com/beyro/dvx-cli package-icon.png MIT - 1.9.0: -- New `report` command to generate a report of plugin registrations in Markdown and CSV + 1.10.0: +- Add column to `plugin report` output files that shows the user the plugin runs as