add unique

pull/8198/head
Medya Gh 2020-05-18 18:26:11 -07:00
parent 80d1c8741d
commit 32bf4d46a7
2 changed files with 13 additions and 1 deletions

View File

@ -341,7 +341,7 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
// Feed Docker our host proxy environment by default, so that it can pull images
// doing this for both new config and existing, in case proxy changed since previous start
if _, ok := r.(*cruntime.Docker); ok && !cmd.Flags().Changed("docker-env") {
if _, ok := r.(*cruntime.Docker); ok {
proxy.SetDockerEnv()
}

View File

@ -168,5 +168,17 @@ func SetDockerEnv() []string {
config.DockerEnv = append(config.DockerEnv, fmt.Sprintf("%s=%s", k, v))
}
}
// remove duplicates
seen := map[string]bool{}
uniqueEnvs := []string{}
for e := range config.DockerEnv {
if !seen[config.DockerEnv[e]] {
seen[config.DockerEnv[e]] = true
uniqueEnvs = append(uniqueEnvs, config.DockerEnv[e])
}
}
config.DockerEnv = uniqueEnvs
return config.DockerEnv
}