|
|
@ -46,6 +46,10 @@ type EnvSettings struct {
|
|
|
|
KubeConfig string
|
|
|
|
KubeConfig string
|
|
|
|
// KubeContext is the name of the kubeconfig context.
|
|
|
|
// KubeContext is the name of the kubeconfig context.
|
|
|
|
KubeContext string
|
|
|
|
KubeContext string
|
|
|
|
|
|
|
|
// Bearer KubeToken used for authentication
|
|
|
|
|
|
|
|
KubeToken string
|
|
|
|
|
|
|
|
// Kubernetes API Server Endpoint for authentication
|
|
|
|
|
|
|
|
KubeAPIServer string
|
|
|
|
// Debug indicates whether or not Helm is running in Debug mode.
|
|
|
|
// Debug indicates whether or not Helm is running in Debug mode.
|
|
|
|
Debug bool
|
|
|
|
Debug bool
|
|
|
|
// RegistryConfig is the path to the registry config file.
|
|
|
|
// RegistryConfig is the path to the registry config file.
|
|
|
@ -63,6 +67,8 @@ func New() *EnvSettings {
|
|
|
|
env := EnvSettings{
|
|
|
|
env := EnvSettings{
|
|
|
|
namespace: os.Getenv("HELM_NAMESPACE"),
|
|
|
|
namespace: os.Getenv("HELM_NAMESPACE"),
|
|
|
|
KubeContext: os.Getenv("HELM_KUBECONTEXT"),
|
|
|
|
KubeContext: os.Getenv("HELM_KUBECONTEXT"),
|
|
|
|
|
|
|
|
KubeToken: os.Getenv("HELM_KUBETOKEN"),
|
|
|
|
|
|
|
|
KubeAPIServer: os.Getenv("HELM_KUBEAPISERVER"),
|
|
|
|
PluginsDirectory: envOr("HELM_PLUGINS", helmpath.DataPath("plugins")),
|
|
|
|
PluginsDirectory: envOr("HELM_PLUGINS", helmpath.DataPath("plugins")),
|
|
|
|
RegistryConfig: envOr("HELM_REGISTRY_CONFIG", helmpath.ConfigPath("registry.json")),
|
|
|
|
RegistryConfig: envOr("HELM_REGISTRY_CONFIG", helmpath.ConfigPath("registry.json")),
|
|
|
|
RepositoryConfig: envOr("HELM_REPOSITORY_CONFIG", helmpath.ConfigPath("repositories.yaml")),
|
|
|
|
RepositoryConfig: envOr("HELM_REPOSITORY_CONFIG", helmpath.ConfigPath("repositories.yaml")),
|
|
|
@ -77,6 +83,8 @@ 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.StringVar(&s.KubeToken, "kube-token", s.KubeToken, "bearer token used for authentication")
|
|
|
|
|
|
|
|
fs.StringVar(&s.KubeAPIServer, "kube-apiserver", s.KubeAPIServer, "the address and the port for the Kubernetes API server")
|
|
|
|
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")
|
|
|
|
fs.StringVar(&s.RepositoryConfig, "repository-config", s.RepositoryConfig, "path to the file containing repository names and URLs")
|
|
|
|
fs.StringVar(&s.RepositoryConfig, "repository-config", s.RepositoryConfig, "path to the file containing repository names and URLs")
|
|
|
@ -100,6 +108,8 @@ func (s *EnvSettings) EnvVars() map[string]string {
|
|
|
|
"HELM_REPOSITORY_CONFIG": s.RepositoryConfig,
|
|
|
|
"HELM_REPOSITORY_CONFIG": s.RepositoryConfig,
|
|
|
|
"HELM_NAMESPACE": s.Namespace(),
|
|
|
|
"HELM_NAMESPACE": s.Namespace(),
|
|
|
|
"HELM_KUBECONTEXT": s.KubeContext,
|
|
|
|
"HELM_KUBECONTEXT": s.KubeContext,
|
|
|
|
|
|
|
|
"HELM_KUBETOKEN": s.KubeToken,
|
|
|
|
|
|
|
|
"HELM_KUBEAPISERVER": s.KubeAPIServer,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if s.KubeConfig != "" {
|
|
|
|
if s.KubeConfig != "" {
|
|
|
@ -124,7 +134,15 @@ func (s *EnvSettings) Namespace() string {
|
|
|
|
//RESTClientGetter gets the kubeconfig from EnvSettings
|
|
|
|
//RESTClientGetter gets the kubeconfig from EnvSettings
|
|
|
|
func (s *EnvSettings) RESTClientGetter() 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)
|
|
|
|
clientConfig := kube.GetConfig(s.KubeConfig, s.KubeContext, s.namespace)
|
|
|
|
|
|
|
|
if len(s.KubeToken) > 0 {
|
|
|
|
|
|
|
|
clientConfig.BearerToken = &s.KubeToken
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(s.KubeAPIServer) > 0 {
|
|
|
|
|
|
|
|
clientConfig.APIServer = &s.KubeAPIServer
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
s.config = clientConfig
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return s.config
|
|
|
|
return s.config
|
|
|
|
}
|
|
|
|
}
|
|
|
|