diff --git a/internal/chart/v3/util/dependencies.go b/internal/chart/v3/util/dependencies.go index d42069894..6bbaf952c 100644 --- a/internal/chart/v3/util/dependencies.go +++ b/internal/chart/v3/util/dependencies.go @@ -55,8 +55,8 @@ func processDependencyConditions(reqs []*chart.Dependency, cvals common.Values, break } logger.Warn("returned non-bool value", "path", c, "chart", r.Name) - } else if errors.As(err, &errNoValue) { - // this is a real error + } else if !errors.As(err, &errNoValue) { + // ErrNoValue means the condition key is absent, which is normal; warn on real errors only logger.Warn("the method PathValue returned error", slog.Any("error", err)) } } diff --git a/internal/plugin/loader.go b/internal/plugin/loader.go index 02c48ee71..eaa8518e2 100644 --- a/internal/plugin/loader.go +++ b/internal/plugin/loader.go @@ -162,6 +162,9 @@ func LoadDir(dirname string) (Plugin, error) { // NewLogIgnorePluginLoadErrorFilterFunc returns an ErrorFilterFunc that logs // plugin load errors using the provided logger and ignores them. func NewLogIgnorePluginLoadErrorFilterFunc(logger *slog.Logger) ErrorFilterFunc { + if logger == nil { + logger = slog.New(slog.DiscardHandler) + } return func(pluginYAML string, err error) error { logger.Warn("failed to load plugin (ignoring)", slog.String("plugin_yaml", pluginYAML), slog.Any("error", err)) return nil diff --git a/pkg/action/action.go b/pkg/action/action.go index a7907d2aa..71bd10ee3 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -157,6 +157,7 @@ func ConfigurationSetLogger(h slog.Handler) ConfigurationOption { func NewConfiguration(options ...ConfigurationOption) *Configuration { c := &Configuration{} + c.SetLogger(slog.NewTextHandler(io.Discard, nil)) for _, o := range options { o(c) diff --git a/pkg/cmd/flags.go b/pkg/cmd/flags.go index 45d1137de..19a5f24c4 100644 --- a/pkg/cmd/flags.go +++ b/pkg/cmd/flags.go @@ -72,6 +72,9 @@ type waitValue struct { func newWaitValue(defaultValue kube.WaitStrategy, ws *kube.WaitStrategy, logger *slog.Logger) *waitValue { *ws = defaultValue + if logger == nil { + logger = slog.New(slog.DiscardHandler) + } return &waitValue{ws: ws, logger: logger} } diff --git a/pkg/cmd/helpers.go b/pkg/cmd/helpers.go index 121ac729d..7fd2a0874 100644 --- a/pkg/cmd/helpers.go +++ b/pkg/cmd/helpers.go @@ -43,6 +43,9 @@ func addDryRunFlag(cmd *cobra.Command) { // Determine the `action.DryRunStrategy` given -dry-run=` flag (or absence of) // Legacy usage of the flag: boolean values, and `--dry-run` (without value) are supported, and log warnings emitted func cmdGetDryRunFlagStrategy(cmd *cobra.Command, isTemplate bool, logger *slog.Logger) (action.DryRunStrategy, error) { + if logger == nil { + logger = slog.New(slog.DiscardHandler) + } f := cmd.Flag("dry-run") v := f.Value.String()