feat: add helmfile template --validate (#1135)
This adds the ability for helmfile to call `helm template --validate` introduced in helm 3. fixes #1105
This commit is contained in:
parent
7c80a859fa
commit
bf22502a2f
8
main.go
8
main.go
|
|
@ -236,6 +236,10 @@ func main() {
|
||||||
Value: 0,
|
Value: 0,
|
||||||
Usage: "maximum number of concurrent downloads of release charts",
|
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{
|
cli.BoolFlag{
|
||||||
Name: "skip-deps",
|
Name: "skip-deps",
|
||||||
Usage: "skip running `helm repo update` and `helm dependency build`",
|
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")
|
return c.c.String("output-dir")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c configImpl) Validate() bool {
|
||||||
|
return c.c.Bool("validate")
|
||||||
|
}
|
||||||
|
|
||||||
func (c configImpl) Concurrency() int {
|
func (c configImpl) Concurrency() int {
|
||||||
return c.c.Int("concurrency")
|
return c.c.Int("concurrency")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1114,7 +1114,7 @@ func (a *App) template(r *Run, c TemplateConfigProvider) (bool, []error) {
|
||||||
opts := &state.TemplateOpts{
|
opts := &state.TemplateOpts{
|
||||||
Set: c.Set(),
|
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 {
|
if templateErrs != nil && len(templateErrs) > 0 {
|
||||||
|
|
|
||||||
|
|
@ -1877,6 +1877,10 @@ func (c configImpl) Args() string {
|
||||||
return "some args"
|
return "some args"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c configImpl) Validate() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (c configImpl) SkipDeps() bool {
|
func (c configImpl) SkipDeps() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
@ -1894,6 +1898,7 @@ type applyConfig struct {
|
||||||
values []string
|
values []string
|
||||||
retainValuesFiles bool
|
retainValuesFiles bool
|
||||||
set []string
|
set []string
|
||||||
|
validate bool
|
||||||
skipDeps bool
|
skipDeps bool
|
||||||
suppressSecrets bool
|
suppressSecrets bool
|
||||||
suppressDiff bool
|
suppressDiff bool
|
||||||
|
|
@ -1917,6 +1922,10 @@ func (a applyConfig) Set() []string {
|
||||||
return a.set
|
return a.set
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a applyConfig) Validate() bool {
|
||||||
|
return a.validate
|
||||||
|
}
|
||||||
|
|
||||||
func (a applyConfig) SkipDeps() bool {
|
func (a applyConfig) SkipDeps() bool {
|
||||||
return a.skipDeps
|
return a.skipDeps
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,7 @@ type TemplateConfigProvider interface {
|
||||||
|
|
||||||
Values() []string
|
Values() []string
|
||||||
Set() []string
|
Set() []string
|
||||||
|
Validate() bool
|
||||||
SkipDeps() bool
|
SkipDeps() bool
|
||||||
OutputDir() string
|
OutputDir() string
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -760,7 +760,7 @@ func (o *TemplateOpts) Apply(opts *TemplateOpts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TemplateReleases wrapper for executing helm template on the releases
|
// 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{}
|
opts := &TemplateOpts{}
|
||||||
for _, o := range opt {
|
for _, o := range opt {
|
||||||
o.Apply(opts)
|
o.Apply(opts)
|
||||||
|
|
@ -832,6 +832,10 @@ func (st *HelmState) TemplateReleases(helm helmexec.Interface, outputDir string,
|
||||||
os.Mkdir(releaseOutputDir, 0755)
|
os.Mkdir(releaseOutputDir, 0755)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if validate {
|
||||||
|
flags = append(flags, "--validate")
|
||||||
|
}
|
||||||
|
|
||||||
if len(errs) == 0 {
|
if len(errs) == 0 {
|
||||||
if err := helm.TemplateRelease(release.Name, temp[release.Name], flags...); err != nil {
|
if err := helm.TemplateRelease(release.Name, temp[release.Name], flags...); err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue