|
|
@ -39,9 +39,11 @@ import (
|
|
|
|
// EnvSettings describes all of the environment settings.
|
|
|
|
// EnvSettings describes all of the environment settings.
|
|
|
|
type EnvSettings struct {
|
|
|
|
type EnvSettings struct {
|
|
|
|
namespace string
|
|
|
|
namespace string
|
|
|
|
kubeConfig string
|
|
|
|
|
|
|
|
config genericclioptions.RESTClientGetter
|
|
|
|
config genericclioptions.RESTClientGetter
|
|
|
|
configOnce sync.Once
|
|
|
|
configOnce sync.Once
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// KubeConfig is the path to the kubeconfig file
|
|
|
|
|
|
|
|
KubeConfig string
|
|
|
|
// KubeContext is the name of the kubeconfig context.
|
|
|
|
// KubeContext is the name of the kubeconfig context.
|
|
|
|
KubeContext string
|
|
|
|
KubeContext string
|
|
|
|
// Debug indicates whether or not Helm is running in Debug mode.
|
|
|
|
// Debug indicates whether or not Helm is running in Debug mode.
|
|
|
@ -73,7 +75,7 @@ func New() *EnvSettings {
|
|
|
|
// AddFlags binds flags to the given flagset.
|
|
|
|
// AddFlags binds flags to the given flagset.
|
|
|
|
func (s *EnvSettings) AddFlags(fs *pflag.FlagSet) {
|
|
|
|
func (s *EnvSettings) AddFlags(fs *pflag.FlagSet) {
|
|
|
|
fs.StringVarP(&s.namespace, "namespace", "n", s.namespace, "namespace scope for this request")
|
|
|
|
fs.StringVarP(&s.namespace, "namespace", "n", s.namespace, "namespace scope for this request")
|
|
|
|
fs.StringVar(&s.kubeConfig, "kubeconfig", "", "path to the kubeconfig file")
|
|
|
|
fs.StringVar(&s.KubeConfig, "kubeconfig", "", "path to the kubeconfig file")
|
|
|
|
fs.StringVar(&s.KubeContext, "kube-context", s.KubeContext, "name of the kubeconfig context to use")
|
|
|
|
fs.StringVar(&s.KubeContext, "kube-context", s.KubeContext, "name of the kubeconfig context to use")
|
|
|
|
fs.BoolVar(&s.Debug, "debug", s.Debug, "enable verbose output")
|
|
|
|
fs.BoolVar(&s.Debug, "debug", s.Debug, "enable verbose output")
|
|
|
|
fs.StringVar(&s.RegistryConfig, "registry-config", s.RegistryConfig, "path to the registry config file")
|
|
|
|
fs.StringVar(&s.RegistryConfig, "registry-config", s.RegistryConfig, "path to the registry config file")
|
|
|
@ -100,8 +102,8 @@ func (s *EnvSettings) EnvVars() map[string]string {
|
|
|
|
"HELM_KUBECONTEXT": s.KubeContext,
|
|
|
|
"HELM_KUBECONTEXT": s.KubeContext,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if s.kubeConfig != "" {
|
|
|
|
if s.KubeConfig != "" {
|
|
|
|
envvars["KUBECONFIG"] = s.kubeConfig
|
|
|
|
envvars["KUBECONFIG"] = s.KubeConfig
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return envvars
|
|
|
|
return envvars
|
|
|
@ -113,16 +115,16 @@ func (s *EnvSettings) Namespace() string {
|
|
|
|
return s.namespace
|
|
|
|
return s.namespace
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ns, _, err := s.KubeConfig().ToRawKubeConfigLoader().Namespace(); err == nil {
|
|
|
|
if ns, _, err := s.RESTClientGetter().ToRawKubeConfigLoader().Namespace(); err == nil {
|
|
|
|
return ns
|
|
|
|
return ns
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "default"
|
|
|
|
return "default"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//KubeConfig gets the kubeconfig from EnvSettings
|
|
|
|
//RESTClientGetter gets the kubeconfig from EnvSettings
|
|
|
|
func (s *EnvSettings) KubeConfig() genericclioptions.RESTClientGetter {
|
|
|
|
func (s *EnvSettings) RESTClientGetter() genericclioptions.RESTClientGetter {
|
|
|
|
s.configOnce.Do(func() {
|
|
|
|
s.configOnce.Do(func() {
|
|
|
|
s.config = kube.GetConfig(s.kubeConfig, s.KubeContext, s.namespace)
|
|
|
|
s.config = kube.GetConfig(s.KubeConfig, s.KubeContext, s.namespace)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return s.config
|
|
|
|
return s.config
|
|
|
|
}
|
|
|
|
}
|
|
|
|