From 3af4232be92cf52d6603f325fed1da07db01db1b Mon Sep 17 00:00:00 2001 From: Jerome Guionnet Date: Wed, 25 Oct 2023 15:59:57 -0700 Subject: [PATCH] ReAdding template file filtering --- modules/helm/template.go | 22 +++++++++---------- .../helm_keda_remote_example_template_test.go | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/helm/template.go b/modules/helm/template.go index 55a4ca7c4..95a727125 100644 --- a/modules/helm/template.go +++ b/modules/helm/template.go @@ -92,17 +92,17 @@ func RenderRemoteTemplateE(t testing.TestingT, options *Options, chartURL string if err != nil { return "", err } - // for _, templateFile := range templateFiles { - // // validate this is a valid template file - // absTemplateFile := filepath.Join(absChartDir, templateFile) - // if !strings.HasPrefix(templateFile, "charts") && !files.FileExists(absTemplateFile) { - // return "", errors.WithStackTrace(TemplateFileNotFoundError{Path: templateFile, ChartDir: absChartDir}) - // } - - // // Note: we only get the abs template file path to check it actually exists, but the `helm template` command - // // expects the relative path from the chart. - // args = append(args, "--show-only", templateFile) - // } + for _, templateFile := range templateFiles { + // validate this is a valid template file + // absTemplateFile := filepath.Join(absChartDir, templateFile) + // if !strings.HasPrefix(templateFile, "charts") && !files.FileExists(absTemplateFile) { + // return "", errors.WithStackTrace(TemplateFileNotFoundError{Path: templateFile, ChartDir: absChartDir}) + // } + + // Note: we only get the abs template file path to check it actually exists, but the `helm template` command + // expects the relative path from the chart. + args = append(args, "--show-only", templateFile) + } // deal extraHelmArgs args = append(args, extraHelmArgs...) diff --git a/test/helm_keda_remote_example_template_test.go b/test/helm_keda_remote_example_template_test.go index ab3fcb003..645fd633e 100644 --- a/test/helm_keda_remote_example_template_test.go +++ b/test/helm_keda_remote_example_template_test.go @@ -61,7 +61,7 @@ func TestHelmKedaRemoteExampleTemplateRenderedDeployment(t *testing.T) { // we want to assert that the template renders without any errors. // Additionally, although we know there is only one yaml file in the template, we deliberately path a templateFiles // arg to demonstrate how to select individual templates to render. - output := helm.RenderRemoteTemplate(t, options, "https://kedacore.github.io/charts", releaseName, []string{"templates/metrics-server/deployment.yamll"}) + output := helm.RenderRemoteTemplate(t, options, "https://kedacore.github.io/charts", releaseName, []string{"templates/metrics-server/deployment.yaml"}) // Now we use kubernetes/client-go library to render the template output into the Deployment struct. This will // ensure the Deployment resource is rendered correctly.