Skip to content

Commit

Permalink
Use KubeEnv in gce/templates.go
Browse files Browse the repository at this point in the history
  • Loading branch information
BigDarkClown authored and Edwinhr716 committed Mar 13, 2024
1 parent 9916027 commit 52be5d2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cluster-autoscaler/cloudprovider/gce/kube_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,22 @@ func (ke KubeEnv) Var(name string) (string, bool) {
val, found := ke.env[name]
return val, found
}

// ParseKubeEnv parses kube-env from its string representation
func ParseKubeEnv(kubeEnvValue string) (KubeEnv, error) {
kubeEnv := make(map[string]string)
err := yaml.Unmarshal([]byte(kubeEnvValue), &kubeEnv)
if err != nil {
return nil, fmt.Errorf("error unmarshalling kubeEnv: %v", err)
}
return kubeEnv, nil
}

// Var extracts variable from KubeEnv
func (ke KubeEnv) Var(name string) (string, bool) {
if ke == nil {
return "", false
}
val, found := ke[name]
return val, found
}

0 comments on commit 52be5d2

Please sign in to comment.