fix(helm): Quote chart names in helm create

Quote chart names when creating charts with helm create.

Fixes #9650

Signed-off-by: Andreas Karis <ak.karis@gmail.com>
pull/9758/head
Andreas Karis 3 years ago
parent db4d20f3ad
commit b73bd29133

@ -21,6 +21,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"regexp"
"testing"
"helm.sh/helm/v3/internal/test/ensure"
@ -59,6 +60,20 @@ func TestCreateCmd(t *testing.T) {
if c.Metadata.APIVersion != chart.APIVersionV2 {
t.Errorf("Wrong API version: %q", c.Metadata.APIVersion)
}
// Test that the name in Chart.yaml is quoted
chartPath := cname + "/Chart.yaml"
fileContent, err := ioutil.ReadFile(chartPath)
if err != nil {
t.Errorf("Got error when reading Chart.yaml at path %q: %q", chartPath, err)
}
m, err := regexp.Match("\nname: \""+cname+"\"\n", fileContent)
if err != nil {
t.Errorf("Could not apply regex for file %q", chartPath)
}
if !m {
t.Errorf("Could not find quoted name in %q", chartPath)
}
}
func TestCreateStarterCmd(t *testing.T) {

@ -78,7 +78,7 @@ const maxChartNameLength = 250
const sep = string(filepath.Separator)
const defaultChartfile = `apiVersion: v2
name: %s
name: "%s"
description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.

Loading…
Cancel
Save