add strict apiVersions for template

Signed-off-by: Brunetti Antoine <MDZP17@ad.insee.intra>
pull/10108/head
Brunetti Antoine 4 years ago
parent 3d1bc72827
commit 81176b2007

@ -182,6 +182,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
f.BoolVar(&client.IsUpgrade, "is-upgrade", false, "set .Release.IsUpgrade instead of .Release.IsInstall")
f.StringVar(&kubeVersion, "kube-version", "", "Kubernetes version used for Capabilities.KubeVersion")
f.StringArrayVarP(&extraAPIs, "api-versions", "a", []string{}, "Kubernetes api versions used for Capabilities.APIVersions")
f.BoolVar(&client.StrictAPIVersions, "strict-api-versions", false, "set api versions to strict mode")
f.BoolVar(&client.UseReleaseName, "release-name", false, "use release name in the output-dir path.")
bindPostRenderFlag(cmd, &client.PostRenderer)

@ -101,6 +101,8 @@ type Install struct {
// (for things like templating). These are ignored if ClientOnly is false
KubeVersion *chartutil.KubeVersion
APIVersions chartutil.VersionSet
// Used by helm template to limit API versions to the one specified in the --api-versions tag
StrictAPIVersions bool
// Used by helm template to render charts with .Release.IsUpgrade. Ignored if Dry-Run is false
IsUpgrade bool
// Used by helm template to add the release as part of OutputDir path
@ -216,7 +218,11 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma
if i.KubeVersion != nil {
i.cfg.Capabilities.KubeVersion = *i.KubeVersion
}
if i.StrictAPIVersions && len(i.APIVersions) > 0 {
i.cfg.Capabilities.APIVersions = i.APIVersions
} else {
i.cfg.Capabilities.APIVersions = append(i.cfg.Capabilities.APIVersions, i.APIVersions...)
}
i.cfg.KubeClient = &kubefake.PrintingKubeClient{Out: ioutil.Discard}
mem := driver.NewMemory()

Loading…
Cancel
Save