Updated to get Helm env Paths and XDG env paths only

Signed-off-by: Vibhav Bobade <vibhav.bobde@gmail.com>
pull/6244/head
Vibhav Bobade 6 years ago
parent 0cc1d31ac2
commit 586780d034

@ -25,10 +25,6 @@ import (
"helm.sh/helm/pkg/helmpath" "helm.sh/helm/pkg/helmpath"
"helm.sh/helm/pkg/helmpath/xdg" "helm.sh/helm/pkg/helmpath/xdg"
"helm.sh/helm/pkg/cli"
"helm.sh/helm/pkg/plugin"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"helm.sh/helm/cmd/helm/require" "helm.sh/helm/cmd/helm/require"
@ -45,7 +41,7 @@ func newEnvCmd(out io.Writer) *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "env", Use: "env",
Short: "environment information in use the Helm client", Short: "Helm client environment information",
Long: envHelp, Long: envHelp,
Args: require.NoArgs, Args: require.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
@ -59,15 +55,12 @@ func newEnvCmd(out io.Writer) *cobra.Command {
type envOptions struct { type envOptions struct {
} }
// run .
func (o *envOptions) run(out io.Writer) error { func (o *envOptions) run(out io.Writer) error {
plugin.SetupPluginEnv(&cli.EnvSettings{}, "", "") o.setHelmPaths()
o.setXdgPaths() o.setXdgPaths()
o.setGoPaths()
for _, prefix := range []string{ for _, prefix := range []string{
"HELM_", "HELM_",
"XDG_", "XDG_",
"GO",
} { } {
for _, e := range os.Environ() { for _, e := range os.Environ() {
if strings.HasPrefix(e, prefix) { if strings.HasPrefix(e, prefix) {
@ -78,11 +71,15 @@ func (o *envOptions) run(out io.Writer) error {
return nil return nil
} }
func (o *envOptions) setXdgPaths() { func (o *envOptions) setHelmPaths() {
for key, val := range map[string]string{ for key, val := range map[string]string{
xdg.CacheHomeEnvVar: helmpath.CachePath(), "HELM_HOME": helmpath.DataPath(),
xdg.ConfigHomeEnvVar: helmpath.ConfigPath(), "HELM_PATH_STARTER": helmpath.DataPath("starters"),
xdg.DataHomeEnvVar: helmpath.DataPath(), "HELM_DEBUG": fmt.Sprint(settings.Debug),
"HELM_REGISTRY_CONFIG": settings.RegistryConfig,
"HELM_PATH_REPOSITORY_FILE": settings.RepositoryConfig,
"HELM_PATH_REPOSITORY_CACHE": settings.RepositoryCache,
"HELM_PLUGIN": settings.PluginsDirectory,
} { } {
if eVal := os.Getenv(key); len(eVal) <= 0 { if eVal := os.Getenv(key); len(eVal) <= 0 {
os.Setenv(key, val) os.Setenv(key, val)
@ -90,10 +87,11 @@ func (o *envOptions) setXdgPaths() {
} }
} }
func (o *envOptions) setGoPaths() { func (o *envOptions) setXdgPaths() {
for key, val := range map[string]string{ for key, val := range map[string]string{
"GOPATH": "~/go", xdg.CacheHomeEnvVar: helmpath.CachePath(),
"GOBIN": "~/go/bin", xdg.ConfigHomeEnvVar: helmpath.ConfigPath(),
xdg.DataHomeEnvVar: helmpath.DataPath(),
} { } {
if eVal := os.Getenv(key); len(eVal) <= 0 { if eVal := os.Getenv(key); len(eVal) <= 0 {
os.Setenv(key, val) os.Setenv(key, val)

Loading…
Cancel
Save