Init helm action by default with no logger, don’t require callers to initialise it.

Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
This commit is contained in:
Guillaume Tardif 2021-02-03 14:20:22 +01:00
parent 7d0be7ad5a
commit e3f1bc99d3
1 changed files with 7 additions and 5 deletions

View File

@ -36,6 +36,8 @@ type Actions struct {
initialize func(f func(format string, v ...interface{})) error
}
const helmDriver = "configmap"
// NewActions new helm action
func NewActions(getter genericclioptions.RESTClientGetter) (*Actions, error) {
if getter == nil {
@ -55,12 +57,16 @@ func NewActions(getter genericclioptions.RESTClientGetter) (*Actions, error) {
}
actions.initialize = func(f func(format string, v ...interface{})) error {
err := actions.Config.Init(getter, namespace, "configmap", f)
err := actions.Config.Init(getter, namespace, helmDriver, f)
if err != nil {
return err
}
return actions.Config.KubeClient.IsReachable()
}
err := actions.initialize(nil) // by default no logger, users might re-initialize with another logger function
if err != nil {
return nil, err
}
return actions, nil
}
@ -105,10 +111,6 @@ func (hc *Actions) Get(name string) (*release.Release, error) {
// ListReleases lists chart releases
func (hc *Actions) ListReleases() ([]compose.Stack, error) {
err := hc.initialize(nil)
if err != nil {
return nil, err
}
actList := action.NewList(hc.Config)
releases, err := actList.Run()
if err != nil {