feat: add template args to be used for template and within apply
Signed-off-by: Kerstin Albers <kerstinzuzej@gmail.com>
This commit is contained in:
parent
1b8f2871f6
commit
2e52967d68
|
|
@ -42,6 +42,7 @@ func NewApplyCmd(globalCfg *config.GlobalImpl) *cobra.Command {
|
||||||
f.BoolVar(&applyOptions.StripTrailingCR, "strip-trailing-cr", false, "strip trailing carriage return on input")
|
f.BoolVar(&applyOptions.StripTrailingCR, "strip-trailing-cr", false, "strip trailing carriage return on input")
|
||||||
f.StringVar(&applyOptions.DiffArgs, "diff-args", "", `pass args to helm helm-diff`)
|
f.StringVar(&applyOptions.DiffArgs, "diff-args", "", `pass args to helm helm-diff`)
|
||||||
f.StringVar(&applyOptions.SyncArgs, "sync-args", "", `pass args to helm upgrade`)
|
f.StringVar(&applyOptions.SyncArgs, "sync-args", "", `pass args to helm upgrade`)
|
||||||
|
f.StringVar(&applyOptions.TemplateArgs, "template-args", "", `pass args to helm template`)
|
||||||
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec")
|
f.StringVar(&globalCfg.GlobalOptions.Args, "args", "", "pass args to helm exec")
|
||||||
f.BoolVar(&applyOptions.SkipCleanup, "skip-cleanup", false, "Stop cleaning up temporary values generated by helmfile and helm-secrets. Useful for debugging. Don't use in production for security")
|
f.BoolVar(&applyOptions.SkipCleanup, "skip-cleanup", false, "Stop cleaning up temporary values generated by helmfile and helm-secrets. Useful for debugging. Don't use in production for security")
|
||||||
f.BoolVar(&applyOptions.SkipCRDs, "skip-crds", false, "if set, no CRDs will be installed on sync. By default, CRDs are installed if not already present")
|
f.BoolVar(&applyOptions.SkipCRDs, "skip-crds", false, "if set, no CRDs will be installed on sync. By default, CRDs are installed if not already present")
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ func NewTemplateCmd(globalCfg *config.GlobalImpl) *cobra.Command {
|
||||||
f.BoolVar(&templateOptions.SkipSchemaValidation, "skip-schema-validation", false, `pass skip-schema-validation to "helm template" or "helm upgrade --install"`)
|
f.BoolVar(&templateOptions.SkipSchemaValidation, "skip-schema-validation", false, `pass skip-schema-validation to "helm template" or "helm upgrade --install"`)
|
||||||
f.StringVar(&templateOptions.KubeVersion, "kube-version", "", `pass --kube-version to "helm template". Overrides kubeVersion in helmfile.yaml`)
|
f.StringVar(&templateOptions.KubeVersion, "kube-version", "", `pass --kube-version to "helm template". Overrides kubeVersion in helmfile.yaml`)
|
||||||
f.StringArrayVar(&templateOptions.ShowOnly, "show-only", nil, `pass --show-only to "helm template"`)
|
f.StringArrayVar(&templateOptions.ShowOnly, "show-only", nil, `pass --show-only to "helm template"`)
|
||||||
|
f.StringVar(&templateOptions.TemplateArgs, "template-args", "", `pass args to helm template`)
|
||||||
|
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -187,6 +187,8 @@ helmDefaults:
|
||||||
- "--suppress-secrets"
|
- "--suppress-secrets"
|
||||||
syncArgs:
|
syncArgs:
|
||||||
- "--labels=app.kubernetes.io/managed-by=helmfile"
|
- "--labels=app.kubernetes.io/managed-by=helmfile"
|
||||||
|
templateArgs:
|
||||||
|
- "--dry-run=server"
|
||||||
# verify the chart before upgrading (only works with packaged charts not directories) (default false)
|
# verify the chart before upgrading (only works with packaged charts not directories) (default false)
|
||||||
verify: true
|
verify: true
|
||||||
keyring: path/to/keyring.gpg
|
keyring: path/to/keyring.gpg
|
||||||
|
|
|
||||||
|
|
@ -236,6 +236,7 @@ func (a *App) Template(c TemplateConfigProvider) error {
|
||||||
Set: c.Set(),
|
Set: c.Set(),
|
||||||
Values: c.Values(),
|
Values: c.Values(),
|
||||||
KubeVersion: c.KubeVersion(),
|
KubeVersion: c.KubeVersion(),
|
||||||
|
TemplateArgs: c.TemplateArgs(),
|
||||||
}, func() {
|
}, func() {
|
||||||
ok, errs = a.template(run, c)
|
ok, errs = a.template(run, c)
|
||||||
})
|
})
|
||||||
|
|
@ -406,6 +407,7 @@ func (a *App) Apply(c ApplyConfigProvider) error {
|
||||||
Validate: c.Validate(),
|
Validate: c.Validate(),
|
||||||
Concurrency: c.Concurrency(),
|
Concurrency: c.Concurrency(),
|
||||||
IncludeTransitiveNeeds: c.IncludeNeeds(),
|
IncludeTransitiveNeeds: c.IncludeNeeds(),
|
||||||
|
TemplateArgs: c.TemplateArgs(),
|
||||||
}, func() {
|
}, func() {
|
||||||
matched, updated, es := a.apply(run, c)
|
matched, updated, es := a.apply(run, c)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2109,6 +2109,7 @@ type configImpl struct {
|
||||||
includeTransitiveNeeds bool
|
includeTransitiveNeeds bool
|
||||||
skipCharts bool
|
skipCharts bool
|
||||||
kubeVersion string
|
kubeVersion string
|
||||||
|
templateArgs string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c configImpl) Selectors() []string {
|
func (c configImpl) Selectors() []string {
|
||||||
|
|
@ -2207,6 +2208,10 @@ func (c configImpl) KubeVersion() string {
|
||||||
return c.kubeVersion
|
return c.kubeVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c configImpl) TemplateArgs() string {
|
||||||
|
return c.templateArgs
|
||||||
|
}
|
||||||
|
|
||||||
func (c configImpl) SkipSchemaValidation() bool {
|
func (c configImpl) SkipSchemaValidation() bool {
|
||||||
return c.skipSchemaValidation
|
return c.skipSchemaValidation
|
||||||
}
|
}
|
||||||
|
|
@ -2246,6 +2251,7 @@ type applyConfig struct {
|
||||||
skipDiffOnInstall bool
|
skipDiffOnInstall bool
|
||||||
syncArgs string
|
syncArgs string
|
||||||
diffArgs string
|
diffArgs string
|
||||||
|
templateArgs string
|
||||||
logger *zap.SugaredLogger
|
logger *zap.SugaredLogger
|
||||||
wait bool
|
wait bool
|
||||||
waitRetries int
|
waitRetries int
|
||||||
|
|
@ -2398,6 +2404,10 @@ func (a applyConfig) DiffArgs() string {
|
||||||
return a.diffArgs
|
return a.diffArgs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a applyConfig) TemplateArgs() string {
|
||||||
|
return a.templateArgs
|
||||||
|
}
|
||||||
|
|
||||||
// helmfile-template-only flags
|
// helmfile-template-only flags
|
||||||
func (a applyConfig) IncludeCRDs() bool {
|
func (a applyConfig) IncludeCRDs() bool {
|
||||||
return a.includeCRDs
|
return a.includeCRDs
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ type ApplyConfigProvider interface {
|
||||||
|
|
||||||
DiffArgs() string
|
DiffArgs() string
|
||||||
SyncArgs() string
|
SyncArgs() string
|
||||||
|
TemplateArgs() string
|
||||||
|
|
||||||
SyncReleaseLabels() bool
|
SyncReleaseLabels() bool
|
||||||
|
|
||||||
|
|
@ -232,6 +233,7 @@ type TemplateConfigProvider interface {
|
||||||
NoHooks() bool
|
NoHooks() bool
|
||||||
KubeVersion() string
|
KubeVersion() string
|
||||||
ShowOnly() []string
|
ShowOnly() []string
|
||||||
|
TemplateArgs() string
|
||||||
|
|
||||||
DAGConfig
|
DAGConfig
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,11 +68,13 @@ type ApplyOptions struct {
|
||||||
SyncArgs string
|
SyncArgs string
|
||||||
// HideNotes is the hide notes flag
|
// HideNotes is the hide notes flag
|
||||||
HideNotes bool
|
HideNotes bool
|
||||||
|
|
||||||
// TakeOwnership is true if the ownership should be taken
|
// TakeOwnership is true if the ownership should be taken
|
||||||
TakeOwnership bool
|
TakeOwnership bool
|
||||||
|
|
||||||
SyncReleaseLabels bool
|
SyncReleaseLabels bool
|
||||||
|
|
||||||
|
// TemplateArgs is the list of arguments to pass to helm template
|
||||||
|
TemplateArgs string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewApply creates a new Apply
|
// NewApply creates a new Apply
|
||||||
|
|
@ -273,3 +275,8 @@ func (a *ApplyImpl) TakeOwnership() bool {
|
||||||
func (a *ApplyImpl) SyncReleaseLabels() bool {
|
func (a *ApplyImpl) SyncReleaseLabels() bool {
|
||||||
return a.ApplyOptions.SyncReleaseLabels
|
return a.ApplyOptions.SyncReleaseLabels
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TemplateArgs returns the TemplateArgs.
|
||||||
|
func (a *ApplyImpl) TemplateArgs() string {
|
||||||
|
return a.ApplyOptions.TemplateArgs
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,8 @@ type TemplateOptions struct {
|
||||||
KubeVersion string
|
KubeVersion string
|
||||||
// Propagate '--show-only` to helm template
|
// Propagate '--show-only` to helm template
|
||||||
ShowOnly []string
|
ShowOnly []string
|
||||||
|
// TemplateArgs
|
||||||
|
TemplateArgs string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTemplateOptions creates a new Apply
|
// NewTemplateOptions creates a new Apply
|
||||||
|
|
@ -158,3 +160,8 @@ func (t *TemplateImpl) KubeVersion() string {
|
||||||
func (t *TemplateImpl) ShowOnly() []string {
|
func (t *TemplateImpl) ShowOnly() []string {
|
||||||
return t.TemplateOptions.ShowOnly
|
return t.TemplateOptions.ShowOnly
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TemplateArgs returns the TemplateArgs
|
||||||
|
func (t *TemplateImpl) TemplateArgs() string {
|
||||||
|
return t.TemplateOptions.TemplateArgs
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1160,6 +1160,7 @@ type ChartPrepareOptions struct {
|
||||||
KubeVersion string
|
KubeVersion string
|
||||||
Set []string
|
Set []string
|
||||||
Values []string
|
Values []string
|
||||||
|
TemplateArgs string
|
||||||
// Delete wait
|
// Delete wait
|
||||||
DeleteWait bool
|
DeleteWait bool
|
||||||
DeleteTimeout int
|
DeleteTimeout int
|
||||||
|
|
@ -1337,6 +1338,10 @@ func (st *HelmState) PrepareCharts(helm helmexec.Interface, dir string, concurre
|
||||||
|
|
||||||
chartifyOpts.Validate = opts.Validate
|
chartifyOpts.Validate = opts.Validate
|
||||||
|
|
||||||
|
if (helmfileCommand == "template" || helmfileCommand == "apply") && opts.TemplateArgs != "" {
|
||||||
|
chartifyOpts.TemplateArgs = opts.TemplateArgs
|
||||||
|
}
|
||||||
|
|
||||||
chartifyOpts.KubeVersion = st.getKubeVersion(release, opts.KubeVersion)
|
chartifyOpts.KubeVersion = st.getKubeVersion(release, opts.KubeVersion)
|
||||||
chartifyOpts.ApiVersions = st.getApiVersions(release)
|
chartifyOpts.ApiVersions = st.getApiVersions(release)
|
||||||
|
|
||||||
|
|
@ -1543,6 +1548,7 @@ type TemplateOpts struct {
|
||||||
ShowOnly []string
|
ShowOnly []string
|
||||||
// Propagate '--skip-schema-validation' to helmv3 template and helm install
|
// Propagate '--skip-schema-validation' to helmv3 template and helm install
|
||||||
SkipSchemaValidation bool
|
SkipSchemaValidation bool
|
||||||
|
TemplateArgs string
|
||||||
}
|
}
|
||||||
|
|
||||||
type TemplateOpt interface{ Apply(*TemplateOpts) }
|
type TemplateOpt interface{ Apply(*TemplateOpts) }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue