diff --git a/main.go b/main.go index b7683f82..6deac562 100644 --- a/main.go +++ b/main.go @@ -236,6 +236,10 @@ func main() { Value: 0, Usage: "maximum number of concurrent downloads of release charts", }, + cli.BoolFlag{ + Name: "validate", + Usage: "validate your manifests against the Kubernetes cluster you are currently pointing at", + }, cli.BoolFlag{ Name: "skip-deps", Usage: "skip running `helm repo update` and `helm dependency build`", @@ -528,6 +532,10 @@ func (c configImpl) OutputDir() string { return c.c.String("output-dir") } +func (c configImpl) Validate() bool { + return c.c.Bool("validate") +} + func (c configImpl) Concurrency() int { return c.c.Int("concurrency") } diff --git a/pkg/app/app.go b/pkg/app/app.go index e1e878b6..077beee6 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -1114,7 +1114,7 @@ func (a *App) template(r *Run, c TemplateConfigProvider) (bool, []error) { opts := &state.TemplateOpts{ Set: c.Set(), } - return subst.TemplateReleases(helm, c.OutputDir(), c.Values(), args, c.Concurrency(), opts) + return subst.TemplateReleases(helm, c.OutputDir(), c.Values(), args, c.Concurrency(), c.Validate(), opts) })) if templateErrs != nil && len(templateErrs) > 0 { diff --git a/pkg/app/app_test.go b/pkg/app/app_test.go index 06c8e211..e2cd86a1 100644 --- a/pkg/app/app_test.go +++ b/pkg/app/app_test.go @@ -1877,6 +1877,10 @@ func (c configImpl) Args() string { return "some args" } +func (c configImpl) Validate() bool { + return true +} + func (c configImpl) SkipDeps() bool { return true } @@ -1894,6 +1898,7 @@ type applyConfig struct { values []string retainValuesFiles bool set []string + validate bool skipDeps bool suppressSecrets bool suppressDiff bool @@ -1917,6 +1922,10 @@ func (a applyConfig) Set() []string { return a.set } +func (a applyConfig) Validate() bool { + return a.validate +} + func (a applyConfig) SkipDeps() bool { return a.skipDeps } diff --git a/pkg/app/config.go b/pkg/app/config.go index bae108ba..0989ee2f 100644 --- a/pkg/app/config.go +++ b/pkg/app/config.go @@ -125,6 +125,7 @@ type TemplateConfigProvider interface { Values() []string Set() []string + Validate() bool SkipDeps() bool OutputDir() string diff --git a/pkg/state/state.go b/pkg/state/state.go index 729eec05..28c3daaa 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -760,7 +760,7 @@ func (o *TemplateOpts) Apply(opts *TemplateOpts) { } // TemplateReleases wrapper for executing helm template on the releases -func (st *HelmState) TemplateReleases(helm helmexec.Interface, outputDir string, additionalValues []string, args []string, workerLimit int, opt ...TemplateOpt) []error { +func (st *HelmState) TemplateReleases(helm helmexec.Interface, outputDir string, additionalValues []string, args []string, workerLimit int, validate bool, opt ...TemplateOpt) []error { opts := &TemplateOpts{} for _, o := range opt { o.Apply(opts) @@ -832,6 +832,10 @@ func (st *HelmState) TemplateReleases(helm helmexec.Interface, outputDir string, os.Mkdir(releaseOutputDir, 0755) } + if validate { + flags = append(flags, "--validate") + } + if len(errs) == 0 { if err := helm.TemplateRelease(release.Name, temp[release.Name], flags...); err != nil { errs = append(errs, err)