NewRootCmd hands logSetup the --debug value and expects it to install a
process-wide slog default, and the commands in pkg/cmd log through the
package-level slog functions. An application embedding the Helm CLI has
two choices today: let SetupLogging replace its own default logger, or
keep its logger and lose Helm's log format and --debug handling.
Add NewRootCmdWithLogger, which takes a func(debug bool) *slog.Logger
and never calls slog.SetDefault. The logger is set on the action
configuration (and so on the Kubernetes client and storage drivers) and
is passed to every command in pkg/cmd, which now log through it instead
of the global slog functions. Export NewLogger so embedders can keep the
Helm CLI's log format without touching the global logger.
NewRootCmd and SetupLogging keep their signatures and behavior: logSetup
still runs first and Helm logs through whatever default it installed.
The exported AddWaitFlag still logs to the slog default logger; commands
built by the root command use an unexported variant that takes the
injected logger.
Refs #31724
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Abdullah Al Mahmud <almahmud.zero@gmail.com>
"wait until resources are ready (up to --timeout). Use '--wait' alone for 'watcher' strategy, or specify one of: 'watcher', 'hookOnly', 'legacy'. Default when flag is omitted: 'hookOnly'.",
f.StringVar(&client.DeletionPropagation,"cascade","background","Must be \"background\", \"orphan\", or \"foreground\". Selects the deletion cascading strategy for the dependents. Defaults to background. Use \"foreground\" with --wait to ensure resources with finalizers are fully deleted before returning.")
f.DurationVar(&client.Timeout,"timeout",300*time.Second,"time to wait for any individual Kubernetes operation (like Jobs for hooks)")
f.StringVar(&client.Description,"description","","add a custom description")