diff --git a/internal/chart/v3/lint/rules/template.go b/internal/chart/v3/lint/rules/template.go index e019fc397..a8ae910eb 100644 --- a/internal/chart/v3/lint/rules/template.go +++ b/internal/chart/v3/lint/rules/template.go @@ -88,7 +88,7 @@ func TemplatesWithSkipSchemaValidation(linter *support.Linter, values map[string // lint ignores import-values // See https://github.com/helm/helm/issues/9658 - if err := chartutil.ProcessDependencies(chart, values, nil); err != nil { + if err := chartutil.ProcessDependencies(chart, values); err != nil { return } diff --git a/internal/chart/v3/lint/rules/values.go b/internal/chart/v3/lint/rules/values.go index b681c75f1..b4a2edb0c 100644 --- a/internal/chart/v3/lint/rules/values.go +++ b/internal/chart/v3/lint/rules/values.go @@ -78,7 +78,7 @@ func validateValuesFile(valuesPath string, overrides map[string]any, skipSchemaV } if !skipSchemaValidation { - return util.ValidateAgainstSingleSchema(coalescedValues, schema, nil) + return util.ValidateAgainstSingleSchema(coalescedValues, schema) } return nil diff --git a/pkg/action/action.go b/pkg/action/action.go index 835860132..a7907d2aa 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -347,7 +347,7 @@ func (cfg *Configuration) renderResources(ch *chart.Chart, values common.Values, // that is also declared in the chart's regular templates). For // "nohooks", hooks skip the post-renderer entirely, matching the // Helm 3 behavior. - sortedHooks, sortedManifests, err := releaseutil.SortManifests(files, nil, releaseutil.InstallOrder) + sortedHooks, sortedManifests, err := releaseutil.SortManifests(files, nil, releaseutil.InstallOrder, cfg.Logger()) if err != nil { for name, content := range files { if strings.TrimSpace(content) == "" { diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index 1806386d0..00939ffa6 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -277,7 +277,7 @@ func (u *Upgrade) prepareUpgrade(name string, chart *chartv2.Chart, vals map[str return nil, nil, false, err } - if err := chartutil.ProcessDependencies(chart, vals, nil); err != nil { + if err := chartutil.ProcessDependencies(chart, vals); err != nil { return nil, nil, false, err } diff --git a/pkg/chart/common/util/jsonschema_test.go b/pkg/chart/common/util/jsonschema_test.go index 87f7c98fa..838d152a1 100644 --- a/pkg/chart/common/util/jsonschema_test.go +++ b/pkg/chart/common/util/jsonschema_test.go @@ -235,13 +235,8 @@ func TestValidateAgainstSchema2020Negative(t *testing.T) { } var errString string -<<<<<<< HEAD if err := ValidateAgainstSchema(chrt, vals); err == nil { t.Fatal("Expected an error, but got nil") -======= - if err := ValidateAgainstSchema(chrt, vals, nil); err == nil { - t.Fatalf("Expected an error, but got nil") ->>>>>>> 6f8673662 (fix(logging): replace global slog usage with dependency-injected loggers) } else { errString = err.Error() } @@ -300,7 +295,7 @@ func TestValidateAgainstSingleSchema_UnresolvedURN_Ignored(t *testing.T) { "$ref": "urn:example:helm:schemas:v1:helm-schema-validation-conditions:v1/helmSchemaValidation-true" }`) vals := map[string]any{"any": "value"} - if err := ValidateAgainstSingleSchema(vals, schema, nil); err != nil { + if err := ValidateAgainstSingleSchema(vals, schema); err != nil { t.Fatalf("expected no error when URN unresolved is ignored, got: %v", err) } } @@ -333,7 +328,7 @@ func TestValidateAgainstSchema_MissingSubchartValues_NoPanic(t *testing.T) { } }() - if err := ValidateAgainstSchema(chrt, vals, nil); err != nil { + if err := ValidateAgainstSchema(chrt, vals); err != nil { t.Fatalf("expected no error when subchart values are missing, got: %v", err) } } @@ -361,7 +356,7 @@ func TestValidateAgainstSchema_SubchartNil_NoPanic(t *testing.T) { } }() - if err := ValidateAgainstSchema(chrt, vals, nil); err != nil { + if err := ValidateAgainstSchema(chrt, vals); err != nil { t.Fatalf("expected no error when subchart values are nil, got: %v", err) } } @@ -390,12 +385,7 @@ func TestValidateAgainstSchema_InvalidSubchartValuesType_NoPanic(t *testing.T) { }() // We expect a non-nil error (invalid type), but crucially no panic. -<<<<<<< HEAD if err := ValidateAgainstSchema(chrt, vals); err == nil { t.Fatal("expected an error when subchart values have invalid type, got nil") -======= - if err := ValidateAgainstSchema(chrt, vals, nil); err == nil { - t.Fatalf("expected an error when subchart values have invalid type, got nil") ->>>>>>> 6f8673662 (fix(logging): replace global slog usage with dependency-injected loggers) } } diff --git a/pkg/chart/v2/lint/rules/template.go b/pkg/chart/v2/lint/rules/template.go index bb4d991d2..94210dec8 100644 --- a/pkg/chart/v2/lint/rules/template.go +++ b/pkg/chart/v2/lint/rules/template.go @@ -119,7 +119,7 @@ func (t *templateLinter) Lint() { // lint ignores import-values // See https://github.com/helm/helm/issues/9658 - if err := chartutil.ProcessDependencies(chart, t.values, nil); err != nil { + if err := chartutil.ProcessDependencies(chart, t.values); err != nil { return } diff --git a/pkg/chart/v2/lint/rules/values.go b/pkg/chart/v2/lint/rules/values.go index 0842fbc80..2c766068c 100644 --- a/pkg/chart/v2/lint/rules/values.go +++ b/pkg/chart/v2/lint/rules/values.go @@ -78,7 +78,7 @@ func validateValuesFile(valuesPath string, overrides map[string]any, skipSchemaV } if !skipSchemaValidation { - return util.ValidateAgainstSingleSchema(coalescedValues, schema, nil) + return util.ValidateAgainstSingleSchema(coalescedValues, schema) } return nil diff --git a/pkg/cmd/root.go b/pkg/cmd/root.go index 808065fff..75697126c 100644 --- a/pkg/cmd/root.go +++ b/pkg/cmd/root.go @@ -177,6 +177,7 @@ func newRootCmdWithConfig(actionConfig *action.Configuration, out io.Writer, arg flags.Parse(args) logger := logSetup(settings.Debug) + slog.SetDefault(logger) actionConfig.SetLogger(logger.Handler()) // Validate color mode setting diff --git a/pkg/cmd/root_test.go b/pkg/cmd/root_test.go index bd6bb7598..4e53e1c82 100644 --- a/pkg/cmd/root_test.go +++ b/pkg/cmd/root_test.go @@ -149,9 +149,9 @@ func TestRootCmdLogger(t *testing.T) { t.Error("expected actionConfig logger to be set, got discard handler") } - // The actionConfig logger should NOT be the global default (we no longer set slog.SetDefault) - if l.Handler() == slog.Default().Handler() { - t.Error("expected actionConfig logger to NOT be the slog default logger") + // slog.SetDefault is called so the global default should use the same handler + if l.Handler() != slog.Default().Handler() { + t.Error("expected actionConfig logger to match the global slog default logger") } } diff --git a/pkg/kube/client_test.go b/pkg/kube/client_test.go index ed871c05a..c5362107b 100644 --- a/pkg/kube/client_test.go +++ b/pkg/kube/client_test.go @@ -21,6 +21,7 @@ import ( "context" "errors" "io" + "log/slog" "net/http" "strings" "sync" @@ -1664,7 +1665,7 @@ func TestPatchResourceClientSide(t *testing.T) { original := resourceListOriginal[0] target := resourceListTarget[0] - err = patchResourceClientSide(original.Object, target, tc.ThreeWayMergeForUnstructured) + err = patchResourceClientSide(original.Object, target, tc.ThreeWayMergeForUnstructured, slog.Default()) if tc.ExpectedErrorContains != "" { require.ErrorContains(t, err, tc.ExpectedErrorContains) } else {