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
@@ -433,6 +433,38 @@ func TestValidateCertIssuerName(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetHelmChart(t *testing.T) {
|
||||
for _, chart := range HelmCharts {
|
||||
got, err := getHelmChart(chart.ReleaseName)
|
||||
if err != nil {
|
||||
t.Fatalf("getHelmChart(%q) unexpected error: %v", chart.ReleaseName, err)
|
||||
}
|
||||
if got.ReleaseName != chart.ReleaseName {
|
||||
t.Fatalf("getHelmChart(%q) returned chart %q", chart.ReleaseName, got.ReleaseName)
|
||||
}
|
||||
}
|
||||
|
||||
for _, name := range []string{"", "not-a-chart", "Traefik"} {
|
||||
_, err := getHelmChart(name)
|
||||
if err == nil {
|
||||
t.Fatalf("getHelmChart(%q) expected an error", name)
|
||||
}
|
||||
if !strings.HasPrefix(err.Error(), fmt.Sprintf("Invalid chart name %q, valid charts: ", name)) {
|
||||
t.Fatalf("getHelmChart(%q) unexpected error: %v", name, err)
|
||||
}
|
||||
|
||||
listed := strings.Split(strings.SplitN(err.Error(), "valid charts: ", 2)[1], ", ")
|
||||
if len(listed) != len(HelmCharts) {
|
||||
t.Fatalf("getHelmChart(%q) listed %d charts, want %d", name, len(listed), len(HelmCharts))
|
||||
}
|
||||
for i := 1; i < len(listed); i++ {
|
||||
if listed[i-1] > listed[i] {
|
||||
t.Fatalf("getHelmChart(%q) listed charts out of order: %v", name, listed)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateLetsencryptServer(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
|
||||
Reference in new issue
Block a user