Add support for kubeContext in environments (#1675)

Resolves #898
Resolves #1689

Co-authored-by: Gregoire Menuel <gregoire.menuel@veolia.com>
This commit is contained in:
Gregoire Menuel 2021-03-23 10:06:53 +01:00 committed by GitHub
parent e9d1c8534c
commit 28cf300ef2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View File

@ -298,6 +298,8 @@ environments:
# Use "Warn", "Info", or "Debug" if you want helmfile to not fail when a values file is missing, while just leaving
# a message about the missing file at the log-level.
missingFileHandler: Error
# kubeContext to use for this environment
kubeContext: kube-context
#
# Advanced Configuration: Layering

View File

@ -1,8 +1,9 @@
package state
type EnvironmentSpec struct {
Values []interface{} `yaml:"values,omitempty"`
Secrets []string `yaml:"secrets,omitempty"`
Values []interface{} `yaml:"values,omitempty"`
Secrets []string `yaml:"secrets,omitempty"`
KubeContext string `yaml:"kubeContext,omitempty"`
// MissingFileHandler instructs helmfile to fail when unable to find a environment values file listed
// under `environments.NAME.values`.

View File

@ -2216,6 +2216,8 @@ func (st *HelmState) connectionFlags(helm helmexec.Interface, release *ReleaseSp
if release.KubeContext != "" {
flags = append(flags, "--kube-context", release.KubeContext)
} else if st.Environments[st.Env.Name].KubeContext != "" {
flags = append(flags, "--kube-context", st.Environments[st.Env.Name].KubeContext)
} else if st.HelmDefaults.KubeContext != "" {
flags = append(flags, "--kube-context", st.HelmDefaults.KubeContext)
}