Changed behavio on environment
- variables are all in values.yaml as "template string". This means that we can now set values to reference others (useful with mapenv label) - we can also set any variable as a secret
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
// InlineConfig is made to represent a configMap or a secret
|
||||
type InlineConfig interface {
|
||||
AddEnvFile(filename string) error
|
||||
AddEnv(key, val string) error
|
||||
Metadata() *Metadata
|
||||
}
|
||||
|
||||
@@ -56,9 +57,12 @@ func (c *ConfigMap) AddEnvFile(file string) error {
|
||||
}
|
||||
c.Data[parts[0]] = parts[1]
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ConfigMap) AddEnv(key, val string) error {
|
||||
c.Data[key] = val
|
||||
return nil
|
||||
}
|
||||
|
||||
// Secret is made to represent a secret with data.
|
||||
@@ -108,3 +112,9 @@ func (s *Secret) AddEnvFile(file string) error {
|
||||
func (s *Secret) Metadata() *Metadata {
|
||||
return s.K8sBase.Metadata
|
||||
}
|
||||
|
||||
// AddEnv adds an environment variable to the secret.
|
||||
func (s *Secret) AddEnv(key, val string) error {
|
||||
s.Data[key] = fmt.Sprintf(`{{ %s | b64enc }}`, val)
|
||||
return nil
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ const (
|
||||
LABEL_SAMEPOD = K + "/same-pod"
|
||||
LABEL_EMPTYDIRS = K + "/empty-dirs"
|
||||
LABEL_IGNORE = K + "/ignore"
|
||||
LABEL_SECRETVARS = K + "/secret-vars"
|
||||
|
||||
//deprecated: use LABEL_MAP_ENV instead
|
||||
LABEL_ENV_SERVICE = K + "/env-to-service"
|
||||
@@ -26,6 +27,7 @@ func GetLabelsDocumentation() string {
|
||||
t, _ := template.New("labels").Parse(`
|
||||
# Labels
|
||||
{{.LABEL_IGNORE | printf "%-33s"}}: ignore the container, it will not yied any object in the helm chart
|
||||
{{.LABEL_SECRETVARS | printf "%-33s"}}: secret variables to push on a secret file
|
||||
{{.LABEL_ENV_SECRET | printf "%-33s"}}: set the given file names as a secret instead of configmap
|
||||
{{.LABEL_MAP_ENV | printf "%-33s"}}: map environment variable to a template string (yaml style)
|
||||
{{.LABEL_PORT | printf "%-33s"}}: set the ports to expose as a service (coma separated)
|
||||
@@ -52,6 +54,7 @@ func GetLabelsDocumentation() string {
|
||||
"LABEL_EMPTYDIRS": LABEL_EMPTYDIRS,
|
||||
"LABEL_IGNORE": LABEL_IGNORE,
|
||||
"LABEL_MAP_ENV": LABEL_MAP_ENV,
|
||||
"LABEL_SECRETVARS": LABEL_SECRETVARS,
|
||||
})
|
||||
return buff.String()
|
||||
}
|
||||
|
Reference in New Issue
Block a user