Do not forget to use MaxChartFileSize and MaxChartFileSize in template

Signed-off-by: Benoit Tigeot <benoit.tigeot@lifen.fr>
pull/30743/head
Benoit Tigeot 2 months ago
parent 892bdf95a9
commit 413fa2ea68
No known key found for this signature in database
GPG Key ID: 8E6D4FC8AEBDA62C

@ -35,6 +35,7 @@ import (
"helm.sh/helm/v4/pkg/action"
"helm.sh/helm/v4/pkg/chart/common"
"helm.sh/helm/v4/pkg/cli"
"helm.sh/helm/v4/pkg/cli/values"
"helm.sh/helm/v4/pkg/cmd/require"
releaseutil "helm.sh/helm/v4/pkg/release/v1/util"
@ -194,6 +195,8 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
f := cmd.Flags()
addInstallFlags(cmd, f, client, valueOpts)
f.Var(cli.NewQuantityBytesValue(&client.MaxChartSize), "max-chart-size", "maximum size for a decompressed chart (e.g., 500Ki, 5Mi)")
f.Var(cli.NewQuantityBytesValue(&client.MaxChartFileSize), "max-file-size", "maximum size for a single file in a chart (e.g., 5Mi, 10Mi)")
f.StringArrayVarP(&showFiles, "show-only", "s", []string{}, "only show manifests rendered from the given templates")
f.StringVar(&client.OutputDir, "output-dir", "", "writes the executed templates to files in output-dir instead of stdout")
f.BoolVar(&validate, "validate", false, "deprecated")

@ -166,6 +166,18 @@ func TestTemplateCmd(t *testing.T) {
cmd: fmt.Sprintf("template '%s' -f %s/extra_values.yaml", chartPath, chartPath),
golden: "output/template-subchart-cm-set-file.txt",
},
{
name: "template with restricted max size (with IEC size)",
cmd: "template too-big testdata/testcharts/oci-dependent-chart-0.1.0.tgz --max-chart-size=1Ki",
wantError: true,
golden: "output/template-with-restricted-chart-size.txt",
},
{
name: "template with restricted max file size",
cmd: "template too-big testdata/testcharts/compressedchart-0.1.0.tgz --max-file-size=10",
wantError: true,
golden: "output/template-with-restricted-file-size.txt",
},
}
runTestCmd(t, tests)
}

@ -0,0 +1 @@
Error: unable to load chart archive: decompressed chart is larger than the maximum size 1Ki

@ -0,0 +1 @@
Error: unable to load chart archive: decompressed chart file "compressedchart/Chart.yaml" is larger than the maximum file size 10
Loading…
Cancel
Save