feat: Add `helmfile template --include-crds` (#1568)
This allows you to use helmfile-template output as a GitOps source, when the template output contains CRDs and you use Helm 3. Helm 3 by default removes CRDs from the template output. If you want to git-commit helmfile-template containing CRDs for GitOps and you use Helm 3 for templating, the only way is provide this newly added `--include-crds` flag.
This commit is contained in:
parent
bdbaa00628
commit
6b86408500
8
main.go
8
main.go
|
|
@ -248,6 +248,10 @@ func main() {
|
||||||
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",
|
||||||
},
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "include-crds",
|
||||||
|
Usage: "include CRDs in the templated output",
|
||||||
|
},
|
||||||
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`",
|
||||||
|
|
@ -717,6 +721,10 @@ func (c configImpl) EmbedValues() bool {
|
||||||
return c.c.Bool("embed-values")
|
return c.c.Bool("embed-values")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c configImpl) IncludeCRDs() bool {
|
||||||
|
return c.c.Bool("include-crds")
|
||||||
|
}
|
||||||
|
|
||||||
func (c configImpl) Logger() *zap.SugaredLogger {
|
func (c configImpl) Logger() *zap.SugaredLogger {
|
||||||
return c.c.App.Metadata["logger"].(*zap.SugaredLogger)
|
return c.c.App.Metadata["logger"].(*zap.SugaredLogger)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1433,6 +1433,7 @@ func (a *App) template(r *Run, c TemplateConfigProvider) (bool, []error) {
|
||||||
|
|
||||||
opts := &state.TemplateOpts{
|
opts := &state.TemplateOpts{
|
||||||
Set: c.Set(),
|
Set: c.Set(),
|
||||||
|
IncludeCRDs: c.IncludeCRDs(),
|
||||||
OutputDirTemplate: c.OutputDirTemplate(),
|
OutputDirTemplate: c.OutputDirTemplate(),
|
||||||
}
|
}
|
||||||
return subst.TemplateReleases(helm, c.OutputDir(), c.Values(), args, c.Concurrency(), c.Validate(), opts)
|
return subst.TemplateReleases(helm, c.OutputDir(), c.Values(), args, c.Concurrency(), c.Validate(), opts)
|
||||||
|
|
|
||||||
|
|
@ -2237,10 +2237,11 @@ services:
|
||||||
}
|
}
|
||||||
|
|
||||||
type configImpl struct {
|
type configImpl struct {
|
||||||
selectors []string
|
selectors []string
|
||||||
set []string
|
set []string
|
||||||
output string
|
output string
|
||||||
skipDeps bool
|
includeCRDs bool
|
||||||
|
skipDeps bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a configImpl) Selectors() []string {
|
func (a configImpl) Selectors() []string {
|
||||||
|
|
@ -2275,6 +2276,10 @@ func (c configImpl) OutputDirTemplate() string {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c configImpl) IncludeCRDs() bool {
|
||||||
|
return c.includeCRDs
|
||||||
|
}
|
||||||
|
|
||||||
func (c configImpl) Concurrency() int {
|
func (c configImpl) Concurrency() int {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,7 @@ type TemplateConfigProvider interface {
|
||||||
Validate() bool
|
Validate() bool
|
||||||
SkipDeps() bool
|
SkipDeps() bool
|
||||||
OutputDir() string
|
OutputDir() string
|
||||||
|
IncludeCRDs() bool
|
||||||
|
|
||||||
concurrencyConfig
|
concurrencyConfig
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1125,6 +1125,7 @@ func (st *HelmState) runHelmDepBuilds(helm helmexec.Interface, concurrency int,
|
||||||
type TemplateOpts struct {
|
type TemplateOpts struct {
|
||||||
Set []string
|
Set []string
|
||||||
OutputDirTemplate string
|
OutputDirTemplate string
|
||||||
|
IncludeCRDs bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type TemplateOpt interface{ Apply(*TemplateOpts) }
|
type TemplateOpt interface{ Apply(*TemplateOpts) }
|
||||||
|
|
@ -1197,6 +1198,10 @@ func (st *HelmState) TemplateReleases(helm helmexec.Interface, outputDir string,
|
||||||
flags = append(flags, "--validate")
|
flags = append(flags, "--validate")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opts.IncludeCRDs {
|
||||||
|
flags = append(flags, "--include-crds")
|
||||||
|
}
|
||||||
|
|
||||||
if len(errs) == 0 {
|
if len(errs) == 0 {
|
||||||
if err := helm.TemplateRelease(release.Name, release.Chart, flags...); err != nil {
|
if err := helm.TemplateRelease(release.Name, release.Chart, flags...); err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue