fix(action): Fixes ordering of variable binding

The recent init action config switched the order of how variables get bound
and where. This led to the namespace variable not being propagated down into
the calls to kubernetes.

Co-authored-by: Matthew Fisher <matt.fisher@microsoft.com>
Signed-off-by: Taylor Thomas <taylor.thomas@microsoft.com>
This commit is contained in:
Taylor Thomas 2019-10-11 11:39:40 -06:00
parent da72944611
commit 01e593fbcd
3 changed files with 13 additions and 14 deletions

View file

@ -64,9 +64,10 @@ func initKubeLogs() {
func main() {
initKubeLogs()
actionConfig, err := action.InitActionConfig(settings, false, os.Getenv("HELM_DRIVER"), debug)
actionConfig := new(action.Configuration)
cmd := newRootCmd(actionConfig, os.Stdout, os.Args[1:])
if err != nil {
if err := actionConfig.Init(settings, false, os.Getenv("HELM_DRIVER"), debug); err != nil {
debug("%+v", err)
switch e := err.(type) {
case pluginError:
@ -76,8 +77,6 @@ func main() {
}
}
cmd := newRootCmd(actionConfig, os.Stdout, os.Args[1:])
if err := cmd.Execute(); err != nil {
debug("%+v", err)
os.Exit(1)

View file

@ -70,7 +70,9 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
Args: require.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if client.AllNamespaces {
action.InitActionConfig(settings, true, os.Getenv("HELM_DRIVER"), debug)
if err := cfg.Init(settings, true, os.Getenv("HELM_DRIVER"), debug); err != nil {
return err
}
}
client.SetStateMask()

View file

@ -210,9 +210,7 @@ func (c *Configuration) recordRelease(r *release.Release) {
}
// InitActionConfig initializes the action configuration
func InitActionConfig(envSettings *cli.EnvSettings, allNamespaces bool, helmDriver string, log DebugLog) (*Configuration, error) {
var actionConfig Configuration
func (c *Configuration) Init(envSettings *cli.EnvSettings, allNamespaces bool, helmDriver string, log DebugLog) error {
kubeconfig := envSettings.KubeConfig()
kc := kube.New(kubeconfig)
@ -220,7 +218,7 @@ func InitActionConfig(envSettings *cli.EnvSettings, allNamespaces bool, helmDriv
clientset, err := kc.Factory.KubernetesClientSet()
if err != nil {
return nil, err
return err
}
var namespace string
if !allNamespaces {
@ -245,10 +243,10 @@ func InitActionConfig(envSettings *cli.EnvSettings, allNamespaces bool, helmDriv
panic("Unknown driver in HELM_DRIVER: " + helmDriver)
}
actionConfig.RESTClientGetter = kubeconfig
actionConfig.KubeClient = kc
actionConfig.Releases = store
actionConfig.Log = log
c.RESTClientGetter = kubeconfig
c.KubeClient = kc
c.Releases = store
c.Log = log
return &actionConfig, nil
return nil
}