feat: add a whole-set form and clear for chart overrides
The `scheduler-k3s:charts:set` command only changed one chart override at a time, so matching a chart's stored overrides to a declared set meant reading the report, computing the difference in both directions and issuing one command per added, changed and removed property, with a failure partway through leaving a mixture of the two sets. A `--replace` flag on `scheduler-k3s:charts:set` now takes a chart name followed by `property=value` pairs and writes the declared map for that chart in a single call. Every pair is parsed before anything is written, so a rejected pair leaves the stored overrides untouched, and a pair ending in `=` stores an empty value, which the per-property form cannot express. An empty pair list is rejected rather than treated as a request to remove everything, and the new `scheduler-k3s:charts:clear` command handles that case by removing every override for a chart.
This commit is contained in:
10 files changed
+278
-42
No files matched your search
@@ -108,12 +108,28 @@ func main() {
|
||||
appName = "--global"
|
||||
}
|
||||
err = scheduler_k3s.CommandAutoscalingAuthReport(appName, *format, *includeMetadata, infoFlag)
|
||||
case "charts:clear":
|
||||
args := flag.NewFlagSet("scheduler-k3s:charts:clear", flag.ExitOnError)
|
||||
args.Parse(os.Args[2:])
|
||||
chartName := args.Arg(0)
|
||||
err = scheduler_k3s.CommandChartsClear(chartName)
|
||||
case "charts:set":
|
||||
args := flag.NewFlagSet("scheduler-k3s:charts:set", flag.ExitOnError)
|
||||
replace := args.Bool("replace", false, "--replace: replace the entire override map for the chart")
|
||||
args.Parse(os.Args[2:])
|
||||
property := args.Arg(0)
|
||||
value := args.Arg(1)
|
||||
err = scheduler_k3s.CommandChartsSet(property, value)
|
||||
input := scheduler_k3s.ChartsSetInput{
|
||||
Replace: *replace,
|
||||
}
|
||||
|
||||
if *replace {
|
||||
input.ChartName = args.Arg(0)
|
||||
input.Pairs = common.VarArgs(args.Args(), 1)
|
||||
} else {
|
||||
input.Property = args.Arg(0)
|
||||
input.Value = args.Arg(1)
|
||||
}
|
||||
|
||||
err = scheduler_k3s.CommandChartsSet(input)
|
||||
case "charts:report":
|
||||
args := flag.NewFlagSet("scheduler-k3s:charts:report", flag.ExitOnError)
|
||||
format := args.String("format", "stdout", "format: [ stdout | json ]")
|
||||
|
||||
Reference in new issue
Block a user