mirror of
https://github.com/helmfile/helmfile.git
synced 2026-09-30 15:06:58 +02:00
* fix: add trackFailOnError option to control kubedog exit code behavior When kubedog release tracking fails (e.g. pod ImagePullBackOff), helmfile exits with code 0 instead of a non-zero exit code. Add a trackFailOnError configuration option (default: false) that when set to true, propagates kubedog tracking failures to the exit code. The option is available as: - Per-release YAML: trackFailOnError: true - CLI flag: --track-fail-on-error (sync and apply commands) Extract trackReleaseIfEnabled helper to consolidate kubedog tracking logic from two duplicated call sites into a single maintainable method. Fixes #2507 Signed-off-by: yxxhero <aiopsclub@163.com> * fix: add //go:build ignore to server.go to fix go test CI failure The test/integration/test-cases/issue-2103/input/server.go is a package main helper binary used by the issue-2103 integration test. When go test -coverprofile runs on this package, it fails with "go: no such tool covdata" in the CI environment. Adding //go:build ignore excludes the file from go list ./... (and therefore from PKGS in the Makefile), while still allowing the integration test to build it explicitly via file path: go build -o server ./path/to/server.go Agent-Logs-Url: https://github.com/helmfile/helmfile/sessions/8a7000af-72b7-48f8-8a82-24813b5df341 Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com> * fix: update TestGenerateID expected hashes after adding TrackFailOnError field Adding TrackFailOnError *bool to ReleaseSpec changed the spew serialization of the struct, which changed the FNV-32a hash values produced by generateValuesID. Update temp_test.go with the new expected hash strings. Agent-Logs-Url: https://github.com/helmfile/helmfile/sessions/caa86cd9-73d1-4894-b745-fd70c0811fd6 Co-authored-by: yxxhero <11087727+yxxhero@users.noreply.github.com> --------- Signed-off-by: yxxhero <aiopsclub@163.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
82 lines
1.6 KiB
Go
82 lines
1.6 KiB
Go
package state
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/google/go-cmp/cmp"
|
|
)
|
|
|
|
func TestGenerateID(t *testing.T) {
|
|
type testcase struct {
|
|
subject string
|
|
release ReleaseSpec
|
|
data any
|
|
want string
|
|
}
|
|
|
|
ids := map[string]int{}
|
|
|
|
run := func(tc testcase) {
|
|
t.Helper()
|
|
|
|
t.Run(tc.subject, func(t *testing.T) {
|
|
t.Helper()
|
|
|
|
got, err := generateValuesID(&tc.release, tc.data)
|
|
if err != nil {
|
|
t.Fatalf("unexpected error: %v", err)
|
|
}
|
|
|
|
if d := cmp.Diff(tc.want, got); d != "" {
|
|
t.Fatalf("unexpected result: want (-), got (+):\n%s", d)
|
|
}
|
|
|
|
ids[got]++
|
|
})
|
|
}
|
|
|
|
run(testcase{
|
|
subject: "baseline",
|
|
release: ReleaseSpec{Name: "foo", Chart: "incubator/raw"},
|
|
want: "foo-values-7f6f8d74dd",
|
|
})
|
|
|
|
run(testcase{
|
|
subject: "different bytes content",
|
|
release: ReleaseSpec{Name: "foo", Chart: "incubator/raw"},
|
|
data: []byte(`{"k":"v"}`),
|
|
want: "foo-values-5fc74c864c",
|
|
})
|
|
|
|
run(testcase{
|
|
subject: "different map content",
|
|
release: ReleaseSpec{Name: "foo", Chart: "incubator/raw"},
|
|
data: map[string]any{"k": "v"},
|
|
want: "foo-values-77df88dd65",
|
|
})
|
|
|
|
run(testcase{
|
|
subject: "different chart",
|
|
release: ReleaseSpec{Name: "foo", Chart: "stable/envoy"},
|
|
want: "foo-values-77c96457f7",
|
|
})
|
|
|
|
run(testcase{
|
|
subject: "different name",
|
|
release: ReleaseSpec{Name: "bar", Chart: "incubator/raw"},
|
|
want: "bar-values-6695f7ff4c",
|
|
})
|
|
|
|
run(testcase{
|
|
subject: "specific ns",
|
|
release: ReleaseSpec{Name: "foo", Chart: "incubator/raw", Namespace: "myns"},
|
|
want: "myns-foo-values-9b9484d4c",
|
|
})
|
|
|
|
for id, n := range ids {
|
|
if n > 1 {
|
|
t.Fatalf("too many occurrences of %s: %d", id, n)
|
|
}
|
|
}
|
|
}
|