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.
57 lines
1.8 KiB
Bash
57 lines
1.8 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load test_helper
|
|
|
|
setup() {
|
|
global_setup
|
|
}
|
|
|
|
teardown() {
|
|
dokku scheduler-k3s:charts:clear cert-manager >/dev/null 2>/dev/null || true
|
|
dokku scheduler-k3s:charts:clear traefik >/dev/null 2>/dev/null || true
|
|
global_teardown
|
|
}
|
|
|
|
@test "(scheduler-k3s:charts:set) accepts property names containing /" {
|
|
run /bin/bash -c "dokku scheduler-k3s:charts:set traefik.service.annotations.prometheus.io/scrape true"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku scheduler-k3s:charts:report traefik --format json | jq -r '.\"traefik.service.annotations.prometheus.io/scrape\"'"
|
|
assert_success
|
|
assert_output "true"
|
|
|
|
run /bin/bash -c "dokku scheduler-k3s:charts:set traefik.service.annotations.prometheus.io/scrape"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku scheduler-k3s:charts:report traefik --format json"
|
|
assert_success
|
|
assert_output "{}"
|
|
}
|
|
|
|
@test "(scheduler-k3s:charts:set) preserves multi-line values" {
|
|
local value=$'line one\nline two\nline three'
|
|
run /bin/bash -c "dokku scheduler-k3s:charts:set traefik.controller.config \"$value\""
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku scheduler-k3s:charts:report traefik --format json | jq -r '.\"traefik.controller.config\"'"
|
|
assert_success
|
|
assert_output "$value"
|
|
}
|
|
|
|
@test "(scheduler-k3s:set) deprecated chart.* form writes through map storage" {
|
|
run /bin/bash -c "dokku scheduler-k3s:set --global chart.cert-manager.installCRDs false"
|
|
assert_success
|
|
assert_output_contains "deprecated"
|
|
|
|
run /bin/bash -c "dokku scheduler-k3s:charts:report cert-manager --format json | jq -r '.\"cert-manager.installCRDs\"'"
|
|
assert_success
|
|
assert_output "false"
|
|
|
|
run /bin/bash -c "dokku scheduler-k3s:set --global chart.cert-manager.installCRDs"
|
|
assert_success
|
|
|
|
run /bin/bash -c "dokku scheduler-k3s:charts:report cert-manager --format json"
|
|
assert_success
|
|
assert_output "{}"
|
|
}
|