Add support for --validate on chartify (#1960)
Apparently we needed to pass `--validate` on helm-template run by chartify when the targeted chart contains Capabilities.APIVersions in a chart template. Otherwise, you can never make such chart work with chartify, as at apply time helm template expressions that involved Capabilities.APIVersions are already nowhere.
This commit is contained in:
parent
0f91f2c9cf
commit
e1cabc82e3
2
go.mod
2
go.mod
|
|
@ -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.8.9
|
github.com/variantdev/chartify v0.9.0
|
||||||
github.com/variantdev/dag v1.0.0
|
github.com/variantdev/dag v1.0.0
|
||||||
github.com/variantdev/vals v0.14.0
|
github.com/variantdev/vals v0.14.0
|
||||||
go.uber.org/multierr v1.6.0
|
go.uber.org/multierr v1.6.0
|
||||||
|
|
|
||||||
2
go.sum
2
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/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 h1:kECyWario6UOShilDThKfuvk+FhXWjlFod/Cg/wTmVs=
|
||||||
github.com/variantdev/chartify v0.8.9/go.mod h1:qF4XzQlkfH/6k2jAi1hLas+lK4zSCa8kY+r5JdmLA68=
|
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 h1:7SFjATxHtrYV20P3tx53yNDBMegz6RT4jv8JPHqAHdM=
|
||||||
github.com/variantdev/dag v1.0.0/go.mod h1:pH1TQsNSLj2uxMo9NNl9zdGy01Wtn+/2MT96BrKmVyE=
|
github.com/variantdev/dag v1.0.0/go.mod h1:pH1TQsNSLj2uxMo9NNl9zdGy01Wtn+/2MT96BrKmVyE=
|
||||||
github.com/variantdev/vals v0.14.0 h1:J+zX1DDLTQ35A198HChVkCwLfA/4OeKhSuZ5zjmgV0Q=
|
github.com/variantdev/vals v0.14.0 h1:J+zX1DDLTQ35A198HChVkCwLfA/4OeKhSuZ5zjmgV0Q=
|
||||||
|
|
|
||||||
11
main.go
11
main.go
|
|
@ -224,6 +224,11 @@ func main() {
|
||||||
Value: 0,
|
Value: 0,
|
||||||
Usage: "maximum number of concurrent helm processes to run, 0 is unlimited",
|
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{
|
cli.IntFlag{
|
||||||
Name: "context",
|
Name: "context",
|
||||||
Value: 0,
|
Value: 0,
|
||||||
|
|
@ -271,7 +276,7 @@ func main() {
|
||||||
},
|
},
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "validate",
|
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{
|
cli.BoolFlag{
|
||||||
Name: "include-crds",
|
Name: "include-crds",
|
||||||
|
|
@ -445,6 +450,10 @@ func main() {
|
||||||
Value: 0,
|
Value: 0,
|
||||||
Usage: "maximum number of concurrent helm processes to run, 0 is unlimited",
|
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{
|
cli.IntFlag{
|
||||||
Name: "context",
|
Name: "context",
|
||||||
Value: 0,
|
Value: 0,
|
||||||
|
|
|
||||||
|
|
@ -172,6 +172,7 @@ func (a *App) Diff(c DiffConfigProvider) error {
|
||||||
SkipRepos: c.SkipDeps(),
|
SkipRepos: c.SkipDeps(),
|
||||||
SkipDeps: c.SkipDeps(),
|
SkipDeps: c.SkipDeps(),
|
||||||
IncludeCRDs: &includeCRDs,
|
IncludeCRDs: &includeCRDs,
|
||||||
|
Validate: c.Validate(),
|
||||||
}, func() {
|
}, func() {
|
||||||
msg, matched, affected, errs = a.diff(run, c)
|
msg, matched, affected, errs = a.diff(run, c)
|
||||||
})
|
})
|
||||||
|
|
@ -238,6 +239,7 @@ func (a *App) Template(c TemplateConfigProvider) error {
|
||||||
SkipDeps: c.SkipDeps(),
|
SkipDeps: c.SkipDeps(),
|
||||||
IncludeCRDs: &includeCRDs,
|
IncludeCRDs: &includeCRDs,
|
||||||
SkipCleanup: c.SkipCleanup(),
|
SkipCleanup: c.SkipCleanup(),
|
||||||
|
Validate: c.Validate(),
|
||||||
}, func() {
|
}, func() {
|
||||||
ok, errs = a.template(run, c)
|
ok, errs = a.template(run, c)
|
||||||
})
|
})
|
||||||
|
|
@ -392,6 +394,7 @@ func (a *App) Apply(c ApplyConfigProvider) error {
|
||||||
WaitForJobs: c.WaitForJobs(),
|
WaitForJobs: c.WaitForJobs(),
|
||||||
IncludeCRDs: &includeCRDs,
|
IncludeCRDs: &includeCRDs,
|
||||||
SkipCleanup: c.RetainValuesFiles() || c.SkipCleanup(),
|
SkipCleanup: c.RetainValuesFiles() || c.SkipCleanup(),
|
||||||
|
Validate: c.Validate(),
|
||||||
}, func() {
|
}, func() {
|
||||||
matched, updated, es := a.apply(run, c)
|
matched, updated, es := a.apply(run, c)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ type ApplyConfigProvider interface {
|
||||||
DiffOutput() string
|
DiffOutput() string
|
||||||
|
|
||||||
RetainValuesFiles() bool
|
RetainValuesFiles() bool
|
||||||
|
Validate() bool
|
||||||
SkipCleanup() bool
|
SkipCleanup() bool
|
||||||
SkipDiffOnInstall() bool
|
SkipDiffOnInstall() bool
|
||||||
|
|
||||||
|
|
@ -90,6 +91,7 @@ type DiffConfigProvider interface {
|
||||||
|
|
||||||
Values() []string
|
Values() []string
|
||||||
Set() []string
|
Set() []string
|
||||||
|
Validate() bool
|
||||||
SkipCRDs() bool
|
SkipCRDs() bool
|
||||||
SkipDeps() bool
|
SkipDeps() bool
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -966,6 +966,9 @@ type ChartPrepareOptions struct {
|
||||||
SkipDeps bool
|
SkipDeps bool
|
||||||
SkipResolve bool
|
SkipResolve bool
|
||||||
SkipCleanup bool
|
SkipCleanup bool
|
||||||
|
// 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
|
IncludeCRDs *bool
|
||||||
Wait bool
|
Wait bool
|
||||||
WaitForJobs bool
|
WaitForJobs bool
|
||||||
|
|
@ -1142,9 +1145,10 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre
|
||||||
if opts.IncludeCRDs != nil {
|
if opts.IncludeCRDs != nil {
|
||||||
includeCRDs = *opts.IncludeCRDs
|
includeCRDs = *opts.IncludeCRDs
|
||||||
}
|
}
|
||||||
|
|
||||||
chartifyOpts.IncludeCRDs = includeCRDs
|
chartifyOpts.IncludeCRDs = includeCRDs
|
||||||
|
|
||||||
|
chartifyOpts.Validate = opts.Validate
|
||||||
|
|
||||||
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}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue