fix(client): Fixes a timing issue with reading client flags

This fixes an issue where the kubernetes client was being created using
command line flags before those flags had been parsed, causing the
client to always use the default values.

Signed-off-by: Ian Howell <ian.howell0@gmail.com>
pull/6025/head
Ian Howell 6 years ago
parent a14e4028a0
commit 4f3b571ba7

@ -65,14 +65,20 @@ func initKubeLogs() {
func main() { func main() {
initKubeLogs() initKubeLogs()
cmd := newRootCmd(newActionConfig(false), os.Stdout, os.Args[1:])
actionConfig := new(action.Configuration)
cmd := newRootCmd(actionConfig, os.Stdout, os.Args[1:])
// Initialize the rest of the actionConfig
initActionConfig(actionConfig, false)
if err := cmd.Execute(); err != nil { if err := cmd.Execute(); err != nil {
logf("%+v", err) logf("%+v", err)
os.Exit(1) os.Exit(1)
} }
} }
func newActionConfig(allNamespaces bool) *action.Configuration { func initActionConfig(actionConfig *action.Configuration, allNamespaces bool) {
kc := kube.New(kubeConfig()) kc := kube.New(kubeConfig())
kc.Log = logf kc.Log = logf
@ -104,12 +110,10 @@ func newActionConfig(allNamespaces bool) *action.Configuration {
panic("Unknown driver in HELM_DRIVER: " + os.Getenv("HELM_DRIVER")) panic("Unknown driver in HELM_DRIVER: " + os.Getenv("HELM_DRIVER"))
} }
return &action.Configuration{ actionConfig.RESTClientGetter = kubeConfig()
RESTClientGetter: kubeConfig(), actionConfig.KubeClient = kc
KubeClient: kc, actionConfig.Releases = store
Releases: store, actionConfig.Log = logf
Log: logf,
}
} }
func kubeConfig() genericclioptions.RESTClientGetter { func kubeConfig() genericclioptions.RESTClientGetter {

@ -64,7 +64,7 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
Args: require.NoArgs, Args: require.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
if client.AllNamespaces { if client.AllNamespaces {
client.SetConfiguration(newActionConfig(true)) initActionConfig(cfg, true)
} }
client.SetStateMask() client.SetStateMask()

Loading…
Cancel
Save