From fd085b33ef6a6b956a338a14b8d40168debbfbde Mon Sep 17 00:00:00 2001 From: suryatech27-cloud Date: Mon, 28 Mar 2022 12:16:27 +0530 Subject: [PATCH] Environment key added for client cert directory. Signed-off-by: Sunil Kumar --- cmd/helm/root.go | 2 +- cmd/helm/testdata/output/env-comp.txt | 2 +- internal/tlsutil/cfg.go | 6 +++--- pkg/cli/environment.go | 26 +++++++++++++------------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cmd/helm/root.go b/cmd/helm/root.go index 1bd1d956a..f0820a42d 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -67,7 +67,7 @@ Environment variables: | $HELM_KUBEASUSER | set the Username to impersonate for the operation. | | $HELM_KUBECONTEXT | set the name of the kubeconfig context. | | $HELM_KUBETOKEN | set the Bearer KubeToken used for authentication. | -| $HELM_SECONDARY_CERT_DIR | set the secondary certificate directory for 2-way ssl support for oci pull. | +| $HELM_CLIENT_TLS_CERT_DIR | set the certificate directory for 2-way tls support for oci pull. | Helm stores cache, configuration, and data based on the following configuration order: diff --git a/cmd/helm/testdata/output/env-comp.txt b/cmd/helm/testdata/output/env-comp.txt index 7a1412b86..f964ce16e 100644 --- a/cmd/helm/testdata/output/env-comp.txt +++ b/cmd/helm/testdata/output/env-comp.txt @@ -15,6 +15,6 @@ HELM_PLUGINS HELM_REGISTRY_CONFIG HELM_REPOSITORY_CACHE HELM_REPOSITORY_CONFIG -HELM_SECONDARY_CERT_DIR +HELM_CLIENT_TLS_CERT_DIR :4 Completion ended with directive: ShellCompDirectiveNoFileComp diff --git a/internal/tlsutil/cfg.go b/internal/tlsutil/cfg.go index e6965b8a1..11aa0cda1 100644 --- a/internal/tlsutil/cfg.go +++ b/internal/tlsutil/cfg.go @@ -68,14 +68,14 @@ func ReadCertFromSecDir(host string) (opts Options, err error) { fmt.Printf("%v OS not supported for this oci pull. Contact your administrator for more information !!!", runtime.GOOS) os.Exit(1) } else { - cmd, err := exec.Command("helm", "env", "HELM_SECONDARY_CERT_DIR").Output() + cmd, err := exec.Command("helm", "env", "HELM_CLIENT_TLS_CERT_DIR").Output() if err != nil { fmt.Printf("Error : %s", err) os.Exit(1) } clientCertDir := strings.TrimSuffix(string(cmd), "\n") if clientCertDir == "" { - fmt.Printf("Please Configure secondary certificate directory for ssl connection set/export HELM_SECONDARY_CERT_DIR='/etc/docker/certs.d/'\n") + fmt.Printf("Please configure client certificate directory for tls connection set/export HELM_CLIENT_TLS_CERT_DIR='/etc/docker/certs.d/'\n") os.Exit(1) } @@ -87,7 +87,7 @@ func ReadCertFromSecDir(host string) (opts Options, err error) { if _, err := os.Stat(clientCertDir); err != nil { if os.IsNotExist(err) { os.MkdirAll(clientCertDir, os.ModePerm) - return opts, errors.Wrapf(err, "Client Certificate Directory Not Exist !! \n %v Directory created.", clientCertDir) + return opts, errors.Wrapf(err, "%v\n%v Directory created.", clientCertDir) } } else { diff --git a/pkg/cli/environment.go b/pkg/cli/environment.go index bf4bb6761..a709ae0e0 100644 --- a/pkg/cli/environment.go +++ b/pkg/cli/environment.go @@ -82,7 +82,7 @@ func New() *EnvSettings { KubeAsGroups: envCSV("HELM_KUBEASGROUPS"), KubeAPIServer: os.Getenv("HELM_KUBEAPISERVER"), KubeCaFile: os.Getenv("HELM_KUBECAFILE"), - ClientSecCertDirectory: envOr("HELM_SECONDARY_CERT_DIR", ""), + ClientSecCertDirectory: envOr("HELM_CLIENT_TLS_CERT_DIR", ""), PluginsDirectory: envOr("HELM_PLUGINS", helmpath.DataPath("plugins")), RegistryConfig: envOr("HELM_REGISTRY_CONFIG", helmpath.ConfigPath("registry/config.json")), RepositoryConfig: envOr("HELM_REPOSITORY_CONFIG", helmpath.ConfigPath("repositories.yaml")), @@ -150,18 +150,18 @@ func envCSV(name string) (ls []string) { func (s *EnvSettings) EnvVars() map[string]string { envvars := map[string]string{ - "HELM_BIN": os.Args[0], - "HELM_CACHE_HOME": helmpath.CachePath(""), - "HELM_CONFIG_HOME": helmpath.ConfigPath(""), - "HELM_DATA_HOME": helmpath.DataPath(""), - "HELM_DEBUG": fmt.Sprint(s.Debug), - "HELM_PLUGINS": s.PluginsDirectory, - "HELM_REGISTRY_CONFIG": s.RegistryConfig, - "HELM_REPOSITORY_CACHE": s.RepositoryCache, - "HELM_REPOSITORY_CONFIG": s.RepositoryConfig, - "HELM_NAMESPACE": s.Namespace(), - "HELM_MAX_HISTORY": strconv.Itoa(s.MaxHistory), - "HELM_SECONDARY_CERT_DIR": s.ClientSecCertDirectory, + "HELM_BIN": os.Args[0], + "HELM_CACHE_HOME": helmpath.CachePath(""), + "HELM_CONFIG_HOME": helmpath.ConfigPath(""), + "HELM_DATA_HOME": helmpath.DataPath(""), + "HELM_DEBUG": fmt.Sprint(s.Debug), + "HELM_PLUGINS": s.PluginsDirectory, + "HELM_REGISTRY_CONFIG": s.RegistryConfig, + "HELM_REPOSITORY_CACHE": s.RepositoryCache, + "HELM_REPOSITORY_CONFIG": s.RepositoryConfig, + "HELM_NAMESPACE": s.Namespace(), + "HELM_MAX_HISTORY": strconv.Itoa(s.MaxHistory), + "HELM_CLIENT_TLS_CERT_DIR": s.ClientSecCertDirectory, // broken, these are populated from helm flags and not kubeconfig. "HELM_KUBECONTEXT": s.KubeContext,