From e61e7a9c6128d309cafdd91241d031143946e1bd Mon Sep 17 00:00:00 2001 From: Aaron Stults Date: Sun, 22 Nov 2020 20:50:40 -0700 Subject: [PATCH] Force input to start at templates/ directory so path matching works as expected. Signed-off-by: Aaron Stults --- cmd/helm/template.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 6123d29d4..db6ab7f9c 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -119,6 +119,17 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { missing := true // Use linux-style filepath separators to unify user's input path f = filepath.ToSlash(f) + // the following path matching assumes starting at the "templates/" directory + // so we will split the input path on "/" and reslice starting at "templates" if it exists + fileSplit := strings.Split(f, "/") + for i,v := range fileSplit { + if v == "templates" { + fileSplit = fileSplit[i:] + break; + } + } + f = strings.Join(fileSplit, "/") + for _, manifestKey := range manifestsKeys { manifest := splitManifests[manifestKey] submatch := manifestNameRegex.FindStringSubmatch(manifest)