diff --git a/go.mod b/go.mod index e1116a93..e3bb72ef 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/spf13/cobra v1.1.1 github.com/tatsushid/go-prettytable v0.0.0-20141013043238-ed2d14c29939 github.com/urfave/cli v1.22.5 - github.com/variantdev/chartify v0.8.9 + github.com/variantdev/chartify v0.9.0 github.com/variantdev/dag v1.0.0 github.com/variantdev/vals v0.14.0 go.uber.org/multierr v1.6.0 diff --git a/go.sum b/go.sum index bd162e60..75f957ab 100644 --- a/go.sum +++ b/go.sum @@ -596,6 +596,8 @@ github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU= github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/variantdev/chartify v0.8.9 h1:kECyWario6UOShilDThKfuvk+FhXWjlFod/Cg/wTmVs= github.com/variantdev/chartify v0.8.9/go.mod h1:qF4XzQlkfH/6k2jAi1hLas+lK4zSCa8kY+r5JdmLA68= +github.com/variantdev/chartify v0.9.0 h1:27Bh3RXqBYyev0Xa1JnfD/LWyZu3SL+iHr6ePMzHdMg= +github.com/variantdev/chartify v0.9.0/go.mod h1:qF4XzQlkfH/6k2jAi1hLas+lK4zSCa8kY+r5JdmLA68= github.com/variantdev/dag v1.0.0 h1:7SFjATxHtrYV20P3tx53yNDBMegz6RT4jv8JPHqAHdM= github.com/variantdev/dag v1.0.0/go.mod h1:pH1TQsNSLj2uxMo9NNl9zdGy01Wtn+/2MT96BrKmVyE= github.com/variantdev/vals v0.14.0 h1:J+zX1DDLTQ35A198HChVkCwLfA/4OeKhSuZ5zjmgV0Q= diff --git a/main.go b/main.go index d837500c..22c3f912 100644 --- a/main.go +++ b/main.go @@ -224,6 +224,11 @@ func main() { Value: 0, Usage: "maximum number of concurrent helm processes to run, 0 is unlimited", }, + cli.BoolFlag{ + Name: "validate", + Usage: "validate your manifests against the Kubernetes cluster you are currently pointing at. Note that this requiers access to a Kubernetes cluster to obtain information necessary for validating, like the list of available API versions", + }, + cli.IntFlag{ Name: "context", Value: 0, @@ -271,7 +276,7 @@ func main() { }, cli.BoolFlag{ Name: "validate", - Usage: "validate your manifests against the Kubernetes cluster you are currently pointing at", + Usage: "validate your manifests against the Kubernetes cluster you are currently pointing at. Note that this requiers access to a Kubernetes cluster to obtain information necessary for validating, like the list of available API versions", }, cli.BoolFlag{ Name: "include-crds", @@ -445,6 +450,10 @@ func main() { Value: 0, Usage: "maximum number of concurrent helm processes to run, 0 is unlimited", }, + cli.BoolFlag{ + Name: "validate", + Usage: "validate your manifests against the Kubernetes cluster you are currently pointing at. Note that this requiers access to a Kubernetes cluster to obtain information necessary for validating, like the list of available API versions", + }, cli.IntFlag{ Name: "context", Value: 0, diff --git a/pkg/app/app.go b/pkg/app/app.go index 96727e93..55183683 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -172,6 +172,7 @@ func (a *App) Diff(c DiffConfigProvider) error { SkipRepos: c.SkipDeps(), SkipDeps: c.SkipDeps(), IncludeCRDs: &includeCRDs, + Validate: c.Validate(), }, func() { msg, matched, affected, errs = a.diff(run, c) }) @@ -238,6 +239,7 @@ func (a *App) Template(c TemplateConfigProvider) error { SkipDeps: c.SkipDeps(), IncludeCRDs: &includeCRDs, SkipCleanup: c.SkipCleanup(), + Validate: c.Validate(), }, func() { ok, errs = a.template(run, c) }) @@ -392,6 +394,7 @@ func (a *App) Apply(c ApplyConfigProvider) error { WaitForJobs: c.WaitForJobs(), IncludeCRDs: &includeCRDs, SkipCleanup: c.RetainValuesFiles() || c.SkipCleanup(), + Validate: c.Validate(), }, func() { matched, updated, es := a.apply(run, c) diff --git a/pkg/app/config.go b/pkg/app/config.go index c6445fc2..b9801ba0 100644 --- a/pkg/app/config.go +++ b/pkg/app/config.go @@ -57,6 +57,7 @@ type ApplyConfigProvider interface { DiffOutput() string RetainValuesFiles() bool + Validate() bool SkipCleanup() bool SkipDiffOnInstall() bool @@ -90,6 +91,7 @@ type DiffConfigProvider interface { Values() []string Set() []string + Validate() bool SkipCRDs() bool SkipDeps() bool diff --git a/pkg/state/state.go b/pkg/state/state.go index 9c3b663a..3ca87a78 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -966,10 +966,13 @@ type ChartPrepareOptions struct { SkipDeps bool SkipResolve bool SkipCleanup bool - IncludeCRDs *bool - Wait bool - WaitForJobs bool - OutputDir string + // Validate is a helm-3-only option. When it is set to true, it configures chartify to pass --validate to helm-template run by it. + // It's required when one of your chart relies on Capabilities.APIVersions in a template + Validate bool + IncludeCRDs *bool + Wait bool + WaitForJobs bool + OutputDir string } type chartPrepareResult struct { @@ -1142,9 +1145,10 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre if opts.IncludeCRDs != nil { includeCRDs = *opts.IncludeCRDs } - chartifyOpts.IncludeCRDs = includeCRDs + chartifyOpts.Validate = opts.Validate + out, err := c.Chartify(release.Name, chartPath, chartify.WithChartifyOpts(chartifyOpts)) if err != nil { results <- &chartPrepareResult{err: err}