Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions internal/action/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package action
import (
"context"
"fmt"
"io"
"log/slog"

helmaction "helm.sh/helm/v4/pkg/action"
Expand Down Expand Up @@ -183,6 +184,10 @@ func (c *ConfigFactory) Build(log slog.Handler, observers ...storage.ObserveFunc
conf.RESTClientGetter = c.Getter
conf.Releases = c.NewStorage(observers...)
conf.KubeClient = client
// Helm's own CLI initialization defaults HookOutputFunc to io.Discard, but
// helmaction.NewConfiguration does not. Without it, hooks annotated with
// helm.sh/hook-output-log-policy make Helm panic on a nil HookOutputFunc.
conf.HookOutputFunc = func(_, _, _ string) io.Writer { return io.Discard }
return conf
}

Expand Down
10 changes: 10 additions & 0 deletions internal/action/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package action

import (
"errors"
"io"
"log/slog"
"testing"

Expand Down Expand Up @@ -257,6 +258,15 @@ func TestConfigFactory_Build(t *testing.T) {
g.Expect(cfg.Releases).ToNot(BeNil())
g.Expect(cfg.Releases.Driver).To(BeAssignableToTypeOf(&storage.Observer{}))
})

t.Run("sets a non-nil HookOutputFunc", func(t *testing.T) {
g := NewWithT(t)

cfg := (&ConfigFactory{}).Build(nil)

g.Expect(cfg.HookOutputFunc).ToNot(BeNil())
g.Expect(cfg.HookOutputFunc("ns", "pod", "container")).To(Equal(io.Discard))
})
}

func TestConfigFactory_Valid(t *testing.T) {
Expand Down