feat(cli+templateengine+deploymanager): resolve follow-ups #4/#5/#6/#8 — CLI ergonomics + structured deploy validation error
Closes the four remaining items in the 2026-06-24 template-inheritance/CLI follow-up tracker. #4 — CLI `instance set-bindings` can now set DataSourceReferenceOverride. `--bindings` accepts an optional 3rd element per entry: [attributeName, dataConnectionId, dataSourceReferenceOverride]. A string sets the override; a JSON null or an omitted 3rd element leaves it unset (template default). TryParseBindings accepts 2- or 3-element entries and rejects a non-string/non-null 3rd element or 4+ elements with a clean error. Previously the CLI sent the override as null and silently wiped any existing one (only a raw POST /management could set it). #5 — `template update` is partial, not full-replace (fixed server-side so all clients benefit). UpdateTemplateAsync now uses leave-unchanged semantics: a null description keeps the stored value (pass "" to clear); a null parentTemplateId keeps the existing parent. Parent stays immutable — a non-null differing value is still rejected — but omitting --parent-id is now a no-op instead of failing every derived-template update. #6 — compact `template list`/`get` table output + `--detail`. Table output is now id/name/description/parent/derived + member counts (#attrs/#alarms/ #scripts/#comps/#nativeAlarms) via TemplateTableProjection, fed through a new optional tableProjector seam on CommandHelpers. `--detail` restores the full dump. JSON output is left untouched (always full) so machine consumers are unaffected — the projector only runs on the table path. #8 — structured deploy-time validation error. New ValidationResult.SummarizeErrors() (Commons) returns a grouped, capped summary: leading total count, one line per ValidationCategory, and a per-module rollup (canonical name up to its last dot) with counts + "... and N more module(s)" caps. DeploymentService uses it for the "Pre-deployment validation failed" message and logs the full per-entry list via LogWarning. Replaces the flat semicolon-joined dump that became a wall of text for instances with 50-194 unbound attributes. Tests: +8 Commons (SummarizeErrors), +8 CLI (4 binding 3-element / 4 table projection), +2 net TemplateEngine (partial-update). Affected suites green: Commons 587, CLI 341, TemplateEngine 447, DeploymentManager 101, ManagementService 230, CentralUI 866; full solution builds 0/0. Docs: Component-DeploymentManager.md "Validation Error Reporting"; CLI README (set-bindings 3-element form, template update leave-unchanged, list/get --detail); UpdateTemplateCommand doc; known-issues tracker #4/#5/#6/#8 resolved (all 8 items now closed).
This commit is contained in:
@@ -54,11 +54,19 @@ public static class TemplateCommands
|
||||
|
||||
private static Command BuildList(Option<string> urlOption, Option<string> formatOption, Option<string> usernameOption, Option<string> passwordOption)
|
||||
{
|
||||
var cmd = new Command("list") { Description = "List all templates" };
|
||||
var detailOption = new Option<bool>("--detail")
|
||||
{
|
||||
Description = "Include full template definitions (all attributes/alarms/scripts) in table output. "
|
||||
+ "Without it, table output is a compact summary (counts only). JSON output is always full."
|
||||
};
|
||||
var cmd = new Command("list") { Description = "List all templates (compact table summary; use --detail for the full dump)" };
|
||||
cmd.Add(detailOption);
|
||||
cmd.SetAction(async (ParseResult result) =>
|
||||
{
|
||||
var detail = result.GetValue(detailOption);
|
||||
return await CommandHelpers.ExecuteCommandAsync(
|
||||
result, urlOption, formatOption, usernameOption, passwordOption, new ListTemplatesCommand());
|
||||
result, urlOption, formatOption, usernameOption, passwordOption, new ListTemplatesCommand(),
|
||||
tableProjector: detail ? null : TemplateTableProjection.ProjectSummary);
|
||||
});
|
||||
return cmd;
|
||||
}
|
||||
@@ -66,13 +74,21 @@ public static class TemplateCommands
|
||||
private static Command BuildGet(Option<string> urlOption, Option<string> formatOption, Option<string> usernameOption, Option<string> passwordOption)
|
||||
{
|
||||
var idOption = new Option<int>("--id") { Description = "Template ID", Required = true };
|
||||
var cmd = new Command("get") { Description = "Get a template by ID" };
|
||||
var detailOption = new Option<bool>("--detail")
|
||||
{
|
||||
Description = "Include full template definitions (all attributes/alarms/scripts) in table output. "
|
||||
+ "Without it, table output is a compact summary (counts only). JSON output is always full."
|
||||
};
|
||||
var cmd = new Command("get") { Description = "Get a template by ID (compact table summary; use --detail for the full dump)" };
|
||||
cmd.Add(idOption);
|
||||
cmd.Add(detailOption);
|
||||
cmd.SetAction(async (ParseResult result) =>
|
||||
{
|
||||
var id = result.GetValue(idOption);
|
||||
var detail = result.GetValue(detailOption);
|
||||
return await CommandHelpers.ExecuteCommandAsync(
|
||||
result, urlOption, formatOption, usernameOption, passwordOption, new GetTemplateCommand(id));
|
||||
result, urlOption, formatOption, usernameOption, passwordOption, new GetTemplateCommand(id),
|
||||
tableProjector: detail ? null : TemplateTableProjection.ProjectSummary);
|
||||
});
|
||||
return cmd;
|
||||
}
|
||||
@@ -103,10 +119,10 @@ public static class TemplateCommands
|
||||
{
|
||||
var idOption = new Option<int>("--id") { Description = "Template ID", Required = true };
|
||||
var nameOption = new Option<string>("--name") { Description = "Template name", Required = true };
|
||||
var descOption = new Option<string?>("--description") { Description = "Template description" };
|
||||
var parentOption = new Option<int?>("--parent-id") { Description = "Parent template ID" };
|
||||
var descOption = new Option<string?>("--description") { Description = "Template description. Omit to leave unchanged; pass an empty string (\"\") to clear it." };
|
||||
var parentOption = new Option<int?>("--parent-id") { Description = "Parent template ID. Immutable after creation; omit to leave unchanged." };
|
||||
|
||||
var cmd = new Command("update") { Description = "Update a template" };
|
||||
var cmd = new Command("update") { Description = "Update a template (omitted optional fields are left unchanged)" };
|
||||
cmd.Add(idOption);
|
||||
cmd.Add(nameOption);
|
||||
cmd.Add(descOption);
|
||||
|
||||
Reference in New Issue
Block a user