Remove ability to have duplicates in environment variables

Signed-off-by: Matt Farina <matt@mattfarina.com>
pull/6353/head
Matt Farina 5 years ago
parent ec31f13ee9
commit 378b9dd29e
No known key found for this signature in database
GPG Key ID: 9436E80BFBA46909

@ -55,8 +55,8 @@ type envOptions struct {
} }
func (o *envOptions) run(out io.Writer) error { func (o *envOptions) run(out io.Writer) error {
for _, e := range o.settings.EnvironmentVariables { for k, v := range o.settings.EnvironmentVariables {
fmt.Printf("%s=\"%s\" \n", e.Name, e.Value) fmt.Printf("%s=\"%s\" \n", k, v)
} }
return nil return nil
} }

@ -52,13 +52,8 @@ type EnvSettings struct {
// PluginsDirectory is the path to the plugins directory. // PluginsDirectory is the path to the plugins directory.
PluginsDirectory string PluginsDirectory string
// Environment Variables Store // Environment Variables Store.
EnvironmentVariables []EnvironmentVariable EnvironmentVariables map[string]string
}
type EnvironmentVariable struct {
Name string
Value string
} }
func New() *EnvSettings { func New() *EnvSettings {
@ -67,7 +62,7 @@ func New() *EnvSettings {
RegistryConfig: helmpath.ConfigPath("registry.json"), RegistryConfig: helmpath.ConfigPath("registry.json"),
RepositoryConfig: helmpath.ConfigPath("repositories.yaml"), RepositoryConfig: helmpath.ConfigPath("repositories.yaml"),
RepositoryCache: helmpath.CachePath("repository"), RepositoryCache: helmpath.CachePath("repository"),
EnvironmentVariables: []EnvironmentVariable{}, EnvironmentVariables: make(map[string]string),
} }
envSettings.setHelmEnvVars() envSettings.setHelmEnvVars()
return &envSettings return &envSettings
@ -118,11 +113,7 @@ func (s *EnvSettings) setHelmEnvVars() {
if eVal := os.Getenv(key); len(eVal) > 0 { if eVal := os.Getenv(key); len(eVal) > 0 {
val = eVal val = eVal
} }
s.EnvironmentVariables = append(s.EnvironmentVariables, s.EnvironmentVariables[key] = val
EnvironmentVariable{
Name: key,
Value: val,
})
} }
} }

Loading…
Cancel
Save