Moved namespace and kubeconfig variable back to original place.

Signed-off-by: Aaron Mell <amell@lumindigital.com>
pull/6341/head
Aaron Mell 6 years ago
parent 1d66a676c8
commit 00249a3235

@ -30,21 +30,20 @@ import (
"github.com/spf13/pflag"
"helm.sh/helm/v3/pkg/helmpath"
"k8s.io/cli-runtime/pkg/genericclioptions"
"helm.sh/helm/v3/pkg/helmpath"
"helm.sh/helm/v3/pkg/kube"
)
// EnvSettings describes all of the environment settings.
type EnvSettings struct {
namespace string
kubeConfig string
// KubeContext is the name of the kubeconfig context.
KubeContext string
// Debug indicates whether or not Helm is running in Debug mode.
Debug bool
// RegistryConfig is the path to the registry config file.
RegistryConfig string
// RepositoryConfig is the path to the repositories file.
@ -58,17 +57,12 @@ type EnvSettings struct {
var (
config genericclioptions.RESTClientGetter
configOnce sync.Once
// Namespace is the namespace scope.
namespace string
// KubeConfig is the path to the kubeconfig file.
kubeConfig string
)
func New() *EnvSettings {
namespace = os.Getenv("HELM_NAMESPACE")
env := EnvSettings{
namespace: os.Getenv("HELM_NAMESPACE"),
PluginsDirectory: envOr("HELM_PLUGINS", helmpath.DataPath("plugins")),
RegistryConfig: envOr("HELM_REGISTRY_CONFIG", helmpath.ConfigPath("registry.json")),
RepositoryConfig: envOr("HELM_REPOSITORY_CONFIG", helmpath.ConfigPath("repositories.yaml")),
@ -80,8 +74,8 @@ func New() *EnvSettings {
// AddFlags binds flags to the given flagset.
func (s *EnvSettings) AddFlags(fs *pflag.FlagSet) {
fs.StringVarP(&namespace, "namespace", "n", namespace, "namespace scope for this request")
fs.StringVar(&kubeConfig, "kubeconfig", "", "path to the kubeconfig file")
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.KubeContext, "kube-context", "", "name of the kubeconfig context to use")
fs.BoolVar(&s.Debug, "debug", s.Debug, "enable verbose output")
fs.StringVar(&s.RegistryConfig, "registry-config", s.RegistryConfig, "path to the registry config file")
@ -109,8 +103,8 @@ func (s *EnvSettings) EnvVars() map[string]string {
//Namespace gets the namespace from the configuration
func (s *EnvSettings) Namespace() string {
if namespace != "" {
return namespace
if s.namespace != "" {
return s.namespace
}
if ns, _, err := s.KubeConfig().ToRawKubeConfigLoader().Namespace(); err == nil {
@ -122,7 +116,7 @@ func (s *EnvSettings) Namespace() string {
//KubeConfig gets the kubeconfig from EnvSettings
func (s *EnvSettings) KubeConfig() genericclioptions.RESTClientGetter {
configOnce.Do(func() {
config = kube.GetConfig(kubeConfig, s.KubeContext, namespace)
config = kube.GetConfig(s.kubeConfig, s.KubeContext, s.namespace)
})
return config
}

Loading…
Cancel
Save