Skip to content

Commit e1cf906

Browse files
committed
Add NewRunnerWithConfig constructor method
This makes it possible to inject a custom Helm action configuration, which is useful for tests where you want to be able to inject a (fake) test client and/or different (memory) storage driver. Signed-off-by: Hidde Beydals <[email protected]>
1 parent c5c58a9 commit e1cf906

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

internal/runner/runner.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,15 @@ type Runner struct {
4545
// namespace configured to the provided values.
4646
func NewRunner(getter genericclioptions.RESTClientGetter, hr *v2.HelmRelease, log logr.Logger) (*Runner, error) {
4747
cfg := new(action.Configuration)
48-
if err := cfg.Init(getter, hr.GetNamespace(), "secret", debugLogger(log)); err != nil {
48+
if err := cfg.Init(getter, hr.GetNamespace(), driver.SecretsDriverName, debugLogger(log)); err != nil {
4949
return nil, err
5050
}
51+
return NewRunnerWithConfig(cfg, hr)
52+
}
53+
54+
// NewRunnerWithConfig constructs a new Runner configured with the
55+
// given action.Configuration.
56+
func NewRunnerWithConfig(cfg *action.Configuration, hr *v2.HelmRelease) (*Runner, error) {
5157
last, err := cfg.Releases.Get(hr.GetReleaseName(), hr.Status.LastReleaseRevision)
5258
if err != nil && !errors.Is(err, driver.ErrReleaseNotFound) {
5359
return nil, err

0 commit comments

Comments
 (0)