From 2ff06a8abdd139a96386127105630ed252c43290 Mon Sep 17 00:00:00 2001 From: Yusuke Kuoka Date: Thu, 8 Apr 2021 10:06:34 +0900 Subject: [PATCH] Fix chartify to take --include-crds into account (#1761) Fixes #1760 --- go.mod | 2 +- go.sum | 2 ++ pkg/app/app.go | 3 +++ pkg/state/state.go | 8 ++++++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 41e8992e..f1f03fc5 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.7.2 + github.com/variantdev/chartify v0.7.3 github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363 github.com/variantdev/vals v0.13.0 go.uber.org/multierr v1.6.0 diff --git a/go.sum b/go.sum index d7ef66bc..89bf970d 100644 --- a/go.sum +++ b/go.sum @@ -579,6 +579,8 @@ github.com/variantdev/chartify v0.7.1 h1:m03k/LDf1skLmOjX8Fj1QmnlaW84BD5iwi1EP56 github.com/variantdev/chartify v0.7.1/go.mod h1:qF4XzQlkfH/6k2jAi1hLas+lK4zSCa8kY+r5JdmLA68= github.com/variantdev/chartify v0.7.2 h1:H7a9xD4rfyKkLDhCO/Oj3VfYnJRb92Dqk+GR6vpUXK4= github.com/variantdev/chartify v0.7.2/go.mod h1:qF4XzQlkfH/6k2jAi1hLas+lK4zSCa8kY+r5JdmLA68= +github.com/variantdev/chartify v0.7.3 h1:uX0mN8PmYHZDWILcg41sQfasJ7TT/CYnYWSmDgsIBIA= +github.com/variantdev/chartify v0.7.3/go.mod h1:qF4XzQlkfH/6k2jAi1hLas+lK4zSCa8kY+r5JdmLA68= github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363 h1:KrfQBEUn+wEOQ/6UIfoqRDvn+Q/wZridQ7t0G1vQqKE= github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363/go.mod h1:pH1TQsNSLj2uxMo9NNl9zdGy01Wtn+/2MT96BrKmVyE= github.com/variantdev/vals v0.13.0 h1:zdtTBjoWKkUGdFauxETkDVjqWXdjUNwI+ggWcUmpxv8= diff --git a/pkg/app/app.go b/pkg/app/app.go index 64fae20e..2c2ef1d4 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -236,12 +236,15 @@ func (a *App) Template(c TemplateConfigProvider) error { opts := []LoadOption{SetRetainValuesFiles(c.SkipCleanup())} return a.ForEachState(func(run *Run) (ok bool, errs []error) { + includeCRDs := c.IncludeCRDs() + // `helm template` in helm v2 does not support local chart. // So, we set forceDownload=true for helm v2 only prepErr := run.withPreparedCharts("template", state.ChartPrepareOptions{ ForceDownload: !run.helm.IsHelm3(), SkipRepos: c.SkipDeps(), SkipDeps: c.SkipDeps(), + IncludeCRDs: &includeCRDs, }, func() { ok, errs = a.template(run, c) }) diff --git a/pkg/state/state.go b/pkg/state/state.go index 1802a8b6..332b4984 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -895,6 +895,7 @@ type ChartPrepareOptions struct { SkipRepos bool SkipDeps bool SkipResolve bool + IncludeCRDs *bool Wait bool WaitForJobs bool OutputDir string @@ -1063,6 +1064,13 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre chartifyOpts.SkipDeps = true } + includeCRDs := true + if opts.IncludeCRDs != nil { + includeCRDs = *opts.IncludeCRDs + } + + chartifyOpts.IncludeCRDs = includeCRDs + out, err := c.Chartify(release.Name, chartPath, chartify.WithChartifyOpts(chartifyOpts)) if err != nil { results <- &chartPrepareResult{err: err}