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:
2022-05-06 09:55:12 +02:00
parent 1e8f417418
commit 1b9ac9ca8a
4 changed files with 92 additions and 18 deletions

View File

@@ -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
}