From c00b869045132fa636c8ee178d23b65dccf1a3cd Mon Sep 17 00:00:00 2001 From: jayste Date: Wed, 3 Jan 2018 08:49:02 +1100 Subject: [PATCH] Added ability to set context in charts.yaml (#21) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added ability to set context in charts.yaml * Added context to the documentation Added error if —kube-context and context are both used. --- README.md | 2 ++ main.go | 8 +++++++- state/state.go | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c2cb9303..863c3cd8 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,8 @@ repositories: - name: roboll url: http://roboll.io/charts +context: kube-context # kube-context (--kube-context) + charts: # Published chart example - name: vault # helm deployment name diff --git a/main.go b/main.go index b7460058..ac6ba583 100644 --- a/main.go +++ b/main.go @@ -225,7 +225,13 @@ func before(c *cli.Context) (*state.HelmState, helmexec.Interface, error) { if err != nil { return nil, nil, err } - + if state.Context != "" { + if kubeContext != "" { + log.Printf("err: Cannot use option --kube-context and set attribute context.") + os.Exit(1) + } + kubeContext = state.Context + } var writer io.Writer if !quiet { writer = os.Stdout diff --git a/state/state.go b/state/state.go index ffd2f03c..d1c52831 100644 --- a/state/state.go +++ b/state/state.go @@ -20,6 +20,7 @@ import ( type HelmState struct { BaseChartPath string + Context string `yaml:"context"` Repositories []RepositorySpec `yaml:"repositories"` Charts []ChartSpec `yaml:"charts"` }