Fix chartify to take --include-crds into account (#1761)

Fixes #1760
This commit is contained in:
Yusuke Kuoka 2021-04-08 10:06:34 +09:00 committed by GitHub
parent d703e17239
commit 2ff06a8abd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 1 deletions

2
go.mod
View File

@ -28,7 +28,7 @@ require (
github.com/spf13/cobra v1.1.1 github.com/spf13/cobra v1.1.1
github.com/tatsushid/go-prettytable v0.0.0-20141013043238-ed2d14c29939 github.com/tatsushid/go-prettytable v0.0.0-20141013043238-ed2d14c29939
github.com/urfave/cli v1.22.5 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/dag v0.0.0-20191028002400-bb0b3c785363
github.com/variantdev/vals v0.13.0 github.com/variantdev/vals v0.13.0
go.uber.org/multierr v1.6.0 go.uber.org/multierr v1.6.0

2
go.sum
View File

@ -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.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 h1:H7a9xD4rfyKkLDhCO/Oj3VfYnJRb92Dqk+GR6vpUXK4=
github.com/variantdev/chartify v0.7.2/go.mod h1:qF4XzQlkfH/6k2jAi1hLas+lK4zSCa8kY+r5JdmLA68= 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 h1:KrfQBEUn+wEOQ/6UIfoqRDvn+Q/wZridQ7t0G1vQqKE=
github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363/go.mod h1:pH1TQsNSLj2uxMo9NNl9zdGy01Wtn+/2MT96BrKmVyE= github.com/variantdev/dag v0.0.0-20191028002400-bb0b3c785363/go.mod h1:pH1TQsNSLj2uxMo9NNl9zdGy01Wtn+/2MT96BrKmVyE=
github.com/variantdev/vals v0.13.0 h1:zdtTBjoWKkUGdFauxETkDVjqWXdjUNwI+ggWcUmpxv8= github.com/variantdev/vals v0.13.0 h1:zdtTBjoWKkUGdFauxETkDVjqWXdjUNwI+ggWcUmpxv8=

View File

@ -236,12 +236,15 @@ func (a *App) Template(c TemplateConfigProvider) error {
opts := []LoadOption{SetRetainValuesFiles(c.SkipCleanup())} opts := []LoadOption{SetRetainValuesFiles(c.SkipCleanup())}
return a.ForEachState(func(run *Run) (ok bool, errs []error) { return a.ForEachState(func(run *Run) (ok bool, errs []error) {
includeCRDs := c.IncludeCRDs()
// `helm template` in helm v2 does not support local chart. // `helm template` in helm v2 does not support local chart.
// So, we set forceDownload=true for helm v2 only // So, we set forceDownload=true for helm v2 only
prepErr := run.withPreparedCharts("template", state.ChartPrepareOptions{ prepErr := run.withPreparedCharts("template", state.ChartPrepareOptions{
ForceDownload: !run.helm.IsHelm3(), ForceDownload: !run.helm.IsHelm3(),
SkipRepos: c.SkipDeps(), SkipRepos: c.SkipDeps(),
SkipDeps: c.SkipDeps(), SkipDeps: c.SkipDeps(),
IncludeCRDs: &includeCRDs,
}, func() { }, func() {
ok, errs = a.template(run, c) ok, errs = a.template(run, c)
}) })

View File

@ -895,6 +895,7 @@ type ChartPrepareOptions struct {
SkipRepos bool SkipRepos bool
SkipDeps bool SkipDeps bool
SkipResolve bool SkipResolve bool
IncludeCRDs *bool
Wait bool Wait bool
WaitForJobs bool WaitForJobs bool
OutputDir string OutputDir string
@ -1063,6 +1064,13 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre
chartifyOpts.SkipDeps = true 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)) out, err := c.Chartify(release.Name, chartPath, chartify.WithChartifyOpts(chartifyOpts))
if err != nil { if err != nil {
results <- &chartPrepareResult{err: err} results <- &chartPrepareResult{err: err}