From 27789f647c3780bc41e7e7c90c5a86809923c02c Mon Sep 17 00:00:00 2001 From: "S.Cavallo" Date: Thu, 9 May 2019 17:11:59 -0400 Subject: [PATCH] add "test-outfile" command and functionality to validate template output update all tests and add fixtures to use the functionality for testing purposes Signed-off-by: S.Cavallo --- cmd/helm/template.go | 111 ++++++++++++- cmd/helm/template_test.go | 157 +++++++----------- .../chart-verify-templates/mariner.yaml | 5 + .../subpop_kube_service.yaml | 58 +++++++ .../subpop_service.yaml | 58 +++++++ .../subpop_set-namespace_service.yaml | 58 +++++++ .../subpop_set-release-install_service.yaml | 58 +++++++ .../subpop_set-release-periods_service.yaml | 58 +++++++ .../subpop_set-release-upgrade_service.yaml | 58 +++++++ .../subpop_set-release_service.yaml | 58 +++++++ .../subpop_subchart1_NOTES.yaml | 61 +++++++ .../subpop_subchart1_service.yaml | 24 +++ .../subpop_subcharta_foobar_service.yaml | 17 ++ .../subpop_template_service.yaml | 58 +++++++ .../subpop_values_service.yaml | 58 +++++++ 15 files changed, 800 insertions(+), 97 deletions(-) create mode 100644 cmd/helm/testdata/testcharts/chart-verify-templates/mariner.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-verify-templates/subpop_kube_service.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-verify-templates/subpop_service.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-namespace_service.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-release-install_service.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-release-periods_service.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-release-upgrade_service.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-release_service.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-verify-templates/subpop_subchart1_NOTES.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-verify-templates/subpop_subchart1_service.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-verify-templates/subpop_subcharta_foobar_service.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-verify-templates/subpop_template_service.yaml create mode 100644 cmd/helm/testdata/testcharts/chart-verify-templates/subpop_values_service.yaml diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 1838bb758..8ad45e958 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -17,9 +17,13 @@ limitations under the License. package main import ( + "bufio" + "bytes" "errors" "fmt" + "github.com/ghodss/yaml" "io" + "io/ioutil" "os" "path" "path/filepath" @@ -28,7 +32,6 @@ import ( "time" "github.com/spf13/cobra" - "k8s.io/apimachinery/pkg/util/validation" "k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/manifest" @@ -76,6 +79,7 @@ type templateCmd struct { renderFiles []string kubeVersion string outputDir string + testOutputFile string } func newTemplateCmd(out io.Writer) *cobra.Command { @@ -104,6 +108,7 @@ func newTemplateCmd(out io.Writer) *cobra.Command { f.StringVar(&t.nameTemplate, "name-template", "", "specify template used to name the release") f.StringVar(&t.kubeVersion, "kube-version", defaultKubeVersion, "kubernetes version used as Capabilities.KubeVersion.Major/Minor") f.StringVar(&t.outputDir, "output-dir", "", "writes the executed templates to files in output-dir instead of stdout") + f.StringVar(&t.testOutputFile, "test-outfile", "", "compares the output against a given file for pass/fail verification") return cmd } @@ -121,6 +126,28 @@ func (t *templateCmd) run(cmd *cobra.Command, args []string) error { return err } + // cannot use output-dir if test-outfile provided + if t.outputDir != "" && t.testOutputFile != "" { + return errors.New("output-dir cannot be used in conjunction with test-outfile") + } + + // if test-outfile is provided + if t.testOutputFile != "" { + // convert test-outfile to absolute path + if !filepath.IsAbs(t.testOutputFile) { + absTestOutputFile, err := filepath.Abs(t.testOutputFile) + if err != nil { + return fmt.Errorf("could not turn test-outfile path %s into absolute path: %s", t.testOutputFile, err) + } + t.testOutputFile = absTestOutputFile + } + // verify that test-outfile exists if provided + _, err := os.Stat(t.testOutputFile) + if os.IsNotExist(err) { + return fmt.Errorf("test-outfile '%s' does not exist", t.testOutputFile) + } + } + // verify that output-dir exists if provided if t.outputDir != "" { _, err := os.Stat(t.outputDir) @@ -226,6 +253,7 @@ func (t *templateCmd) run(cmd *cobra.Command, args []string) error { manifestsToRender = listManifests } + var sb strings.Builder for _, m := range tiller.SortByKind(manifestsToRender) { data := m.Content b := filepath.Base(m.Name) @@ -247,8 +275,31 @@ func (t *templateCmd) run(cmd *cobra.Command, args []string) error { } continue } - fmt.Printf("---\n# Source: %s\n", m.Name) - fmt.Println(data) + + if t.testOutputFile != "" { + sb.WriteString(fmt.Sprintf("---\n# Source: %s\n", m.Name)) + sb.WriteString(data) + } else { + fmt.Printf("---\n# Source: %s\n", m.Name) + fmt.Println(data) + } + } + + if t.testOutputFile != "" { + testOutputFile, err := readTestOutputFile(t.testOutputFile) + if err != nil { + return err + } + expected := normalizeOutput(testOutputFile) + actual := normalizeOutput(sb.String()) + + if expected == actual { + fmt.Println("verification passed") + fmt.Println(sb.String()) + } else { + return fmt.Errorf("verification failed\n%s", sb.String()) + fmt.Println(sb.String()) + } } return nil } @@ -289,3 +340,57 @@ func ensureDirectoryForFile(file string) error { return os.MkdirAll(baseDir, defaultDirectoryPermission) } + +// read the test output file from disk +func readTestOutputFile(file string) (string, error) { + expectedAbsValue, err := filepath.Abs(file) + expectedFile, err := ioutil.ReadFile(expectedAbsValue) + if err != nil { + return "", err + } + expectedValue := string(expectedFile) + return expectedValue, nil +} + +// marshal and unmarshal the string to ease yaml comparison +func normalizeOutput(o string) string { + f := removeNewlineSuffix(o) + m := scanIntoMap(f) + yaml := mapToYaml(m) + return yaml +} + +// remove all trailing newlines to ease string comparisons +func removeNewlineSuffix(y string) string { + if strings.HasSuffix(y, "\n"){ + y = strings.TrimSuffix(y, "\n") + y = removeNewlineSuffix(y) + } + return y +} + +// convert map[string]string to yaml +func mapToYaml(m map[string]string) string { + yml, err := yaml.Marshal(m) + if err != nil { + fmt.Fprintln(os.Stderr, err) + } + val := string(yml) + return val +} + +// convert yaml to map[string]string +func scanIntoMap(yaml string) map[string]string { + b := bytes.NewBuffer([]byte(yaml)) + // scan yaml into map[]yaml + scanner := bufio.NewScanner(b) + lastKey := "" + m := map[string]string{} + for scanner.Scan() { + m[lastKey] = m[lastKey] + scanner.Text() + "\n" + } + if err := scanner.Err(); err != nil { + fmt.Fprintln(os.Stderr, err) + } + return m +} diff --git a/cmd/helm/template_test.go b/cmd/helm/template_test.go index 3c5026b08..ac93a48aa 100644 --- a/cmd/helm/template_test.go +++ b/cmd/helm/template_test.go @@ -17,7 +17,6 @@ limitations under the License. package main import ( - "bufio" "bytes" "fmt" "io" @@ -30,10 +29,12 @@ import ( var ( subchart1ChartPath = "./../../pkg/chartutil/testdata/subpop/charts/subchart1" frobnitzChartPath = "./../../pkg/chartutil/testdata/frobnitz" + fixturePath = "testdata/testcharts/chart-verify-templates" ) func TestTemplateCmd(t *testing.T) { subchart1AbsChartPath, err := filepath.Abs(subchart1ChartPath) + fixtureAbsPath, err := filepath.Abs(fixturePath) if err != nil { t.Fatal(err) } @@ -41,30 +42,20 @@ func TestTemplateCmd(t *testing.T) { name string desc string args []string - expectKey string expectValue string expectError string }{ { name: "check_name", desc: "check for a known name in chart", - args: []string{subchart1ChartPath}, - expectKey: "subchart1/templates/service.yaml", - expectValue: "protocol: TCP\n name: nginx", + args: []string{subchart1ChartPath, "--test-outfile", filepath.Join(fixtureAbsPath, "subpop_service.yaml")}, + expectValue: "verification passed", }, { name: "check_set_name", desc: "verify --set values exist", - args: []string{subchart1ChartPath, "-x", "templates/service.yaml", "--set", "service.name=apache"}, - expectKey: "subchart1/templates/service.yaml", - expectValue: "protocol: TCP\n name: apache", - }, - { - name: "check_execute", - desc: "verify --execute single template", - args: []string{subchart1ChartPath, "-x", "templates/service.yaml", "--set", "service.name=apache"}, - expectKey: "subchart1/templates/service.yaml", - expectValue: "protocol: TCP\n name: apache", + args: []string{subchart1ChartPath, "-x", "templates/service.yaml", "--set", "service.name=apache", "--test-outfile", filepath.Join(fixturePath, "subpop_subchart1_service.yaml")}, + expectValue: "verification passed", }, { name: "check_execute_non_existent", @@ -75,86 +66,74 @@ func TestTemplateCmd(t *testing.T) { { name: "check_execute_absolute", desc: "verify --execute single template", - args: []string{subchart1ChartPath, "-x", filepath.Join(subchart1AbsChartPath, "templates", "service.yaml"), "--set", "service.name=apache"}, - expectKey: "subchart1/templates/service.yaml", - expectValue: "protocol: TCP\n name: apache", + args: []string{subchart1ChartPath, "-x", filepath.Join(subchart1AbsChartPath, "templates", "service.yaml"), "--set", "service.name=apache", "--test-outfile", filepath.Join(fixturePath, "subpop_subchart1_service.yaml")}, + expectValue: "verification passed", }, { name: "check_execute_subchart_template", desc: "verify --execute single template on a subchart template", - args: []string{subchart1ChartPath, "-x", "charts/subcharta/templates/service.yaml", "--set", "subcharta.service.name=foobar"}, - expectKey: "subchart1/charts/subcharta/templates/service.yaml", - expectValue: "protocol: TCP\n name: foobar", + args: []string{subchart1ChartPath, "-x", "charts/subcharta/templates/service.yaml", "--set", "subcharta.service.name=foobar", "--test-outfile", filepath.Join(fixturePath, "subpop_subcharta_foobar_service.yaml")}, + expectValue: "verification passed", }, { name: "check_execute_subchart_template_for_tgz_subchart", desc: "verify --execute single template on a subchart template where the subchart is a .tgz in the chart directory", - args: []string{frobnitzChartPath, "-x", "charts/mariner/templates/placeholder.tpl", "--set", "mariner.name=moon"}, - expectKey: "frobnitz/charts/mariner/templates/placeholder.tpl", + args: []string{frobnitzChartPath, "-x", "charts/mariner/templates/placeholder.tpl", "--set", "mariner.name=moon", "--test-outfile", filepath.Join(fixturePath, "mariner.yaml")}, expectValue: "Goodbye moon", }, { name: "check_namespace", desc: "verify --namespace", - args: []string{subchart1ChartPath, "--namespace", "test"}, - expectKey: "subchart1/templates/service.yaml", - expectValue: "namespace: \"test\"", + args: []string{subchart1ChartPath, "--namespace", "test", "--test-outfile", filepath.Join(fixturePath, "subpop_set-namespace_service.yaml")}, + expectValue: "verification passed", }, { name: "check_release_name", desc: "verify --release exists", - args: []string{subchart1ChartPath, "--name", "test"}, - expectKey: "subchart1/templates/service.yaml", - expectValue: "release-name: \"test\"", + args: []string{subchart1ChartPath, "--name", "test", "--test-outfile", filepath.Join(fixturePath, "subpop_set-release_service.yaml")}, + expectValue: "verification passed", }, { name: "check_invalid_name_uppercase", desc: "verify the release name using capitals is invalid", args: []string{subchart1ChartPath, "--name", "FOO"}, - expectKey: "subchart1/templates/service.yaml", expectError: "is invalid", }, { - name: "check_invalid_name_uppercase", - desc: "verify the release name using periods is invalid", - args: []string{subchart1ChartPath, "--name", "foo.bar"}, - expectKey: "subchart1/templates/service.yaml", - expectValue: "release-name: \"foo.bar\"", + name: "check_release_name_periods", + desc: "verify the release name using periods is valid", + args: []string{subchart1ChartPath, "--name", "foo.bar", "--test-outfile", filepath.Join(fixturePath, "subpop_set-release-periods_service.yaml")}, + expectValue: "verification passed", }, { name: "check_invalid_name_uppercase", desc: "verify the release name using underscores is invalid", args: []string{subchart1ChartPath, "--name", "foo_bar"}, - expectKey: "subchart1/templates/service.yaml", expectError: "is invalid", }, { name: "check_release_is_install", desc: "verify --is-upgrade toggles .Release.IsInstall", - args: []string{subchart1ChartPath, "--is-upgrade=false"}, - expectKey: "subchart1/templates/service.yaml", - expectValue: "release-is-install: \"true\"", + args: []string{subchart1ChartPath, "--is-upgrade=false", "--test-outfile", filepath.Join(fixturePath, "subpop_set-release-install_service.yaml")}, + expectValue: "verification passed", }, { name: "check_release_is_upgrade", desc: "verify --is-upgrade toggles .Release.IsUpgrade", - args: []string{subchart1ChartPath, "--is-upgrade", "true"}, - expectKey: "subchart1/templates/service.yaml", - expectValue: "release-is-upgrade: \"true\"", + args: []string{subchart1ChartPath, "--is-upgrade", "true", "--test-outfile", filepath.Join(fixturePath, "subpop_set-release-upgrade_service.yaml")}, + expectValue: "verification passed", }, { name: "check_notes", desc: "verify --notes shows notes", - args: []string{subchart1ChartPath, "--notes", "true"}, - expectKey: "subchart1/templates/NOTES.txt", - expectValue: "Sample notes for subchart1", + args: []string{subchart1ChartPath, "--notes", "true", "--test-outfile", filepath.Join(fixturePath, "subpop_subchart1_NOTES.yaml")}, + expectValue: "verification passed", }, { name: "check_values_files", desc: "verify --values files values exist", - args: []string{subchart1ChartPath, "--values", subchart1ChartPath + "/charts/subchartA/values.yaml"}, - expectKey: "subchart1/templates/service.yaml", - expectValue: "name: apache", + args: []string{subchart1ChartPath, "--values", subchart1ChartPath + "/charts/subchartA/values.yaml", "--test-outfile", filepath.Join(fixturePath, "subpop_values_service.yaml")}, + expectValue: "verification passed", }, { name: "check_invalid_name_template", @@ -165,16 +144,14 @@ func TestTemplateCmd(t *testing.T) { { name: "check_name_template", desc: "verify --name-template result exists", - args: []string{subchart1ChartPath, "--name-template", "foobar-{{ lower \"ABC\" }}-baz"}, - expectKey: "subchart1/templates/service.yaml", - expectValue: "release-name: \"foobar-abc-baz\"", + args: []string{subchart1ChartPath, "--name-template", "foobar-{{ lower \"ABC\" }}-baz", "--test-outfile", filepath.Join(fixturePath, "subpop_template_service.yaml")}, + expectValue: "verification passed", }, { name: "check_kube_version", desc: "verify --kube-version overrides the kubernetes version", - args: []string{subchart1ChartPath, "--kube-version", "1.6"}, - expectKey: "subchart1/templates/service.yaml", - expectValue: "kube-version/major: \"1\"\n kube-version/minor: \"6\"\n kube-version/gitversion: \"v1.6.0\"", + args: []string{subchart1ChartPath, "--kube-version", "1.6", "--test-outfile", filepath.Join(fixturePath, "subpop_kube_service.yaml")}, + expectValue: "verification passed", }, } @@ -183,17 +160,11 @@ func TestTemplateCmd(t *testing.T) { tt := tt t.Run(tt.name, func(t *testing.T) { // capture stdout - old := os.Stdout - r, w, _ := os.Pipe() - os.Stdout = w - // execute template command - out := bytes.NewBuffer(nil) - cmd := newTemplateCmd(out) - cmd.SetArgs(tt.args) - err := cmd.Execute() + commandOutput, err := runCommandAndReturnOutput(tt.args) if tt.expectError != "" { if err == nil { + fmt.Println(tt.args) t.Errorf("expected err: %s, but no error occurred", tt.expectError) } // non nil error, check if it contains the expected error @@ -202,44 +173,42 @@ func TestTemplateCmd(t *testing.T) { // done return } + fmt.Println(tt.args) t.Fatalf("expected err: %q, got: %q", tt.expectError, err) } else if err != nil { + fmt.Println(tt.args) t.Errorf("expected no error, got %v", err) } - // restore stdout - w.Close() - os.Stdout = old - var b bytes.Buffer - io.Copy(&b, r) - r.Close() - // scan yaml into map[]yaml - scanner := bufio.NewScanner(&b) - next := false - lastKey := "" - m := map[string]string{} - for scanner.Scan() { - if scanner.Text() == "---" { - next = true - } else if next { - // remove '# Source: ' - head := "# Source: " - lastKey = scanner.Text()[len(head):] - next = false - } else { - m[lastKey] = m[lastKey] + scanner.Text() + "\n" - } - } - if err := scanner.Err(); err != nil { - fmt.Fprintln(os.Stderr, "reading standard input:", err) - } - if v, ok := m[tt.expectKey]; ok { - if !strings.Contains(v, tt.expectValue) { - t.Errorf("failed to match expected value %s in %s", tt.expectValue, v) - } - } else { - t.Errorf("could not find key %s", tt.expectKey) + + + if !strings.Contains(commandOutput, tt.expectValue) { + fmt.Println(tt.args) + t.Errorf("failed to match expected value (%s)\n in\n %s", tt.expectValue, commandOutput) } buf.Reset() }) } } + +func runCommandAndReturnOutput(args []string) (string, error) { + // capture stdout + old := os.Stdout + r, w, _ := os.Pipe() + os.Stdout = w + os.Stderr = w + // execute template command + out := bytes.NewBuffer(nil) + cmd := newTemplateCmd(out) + cmd.SetArgs(args) + err := cmd.Execute() + + // restore stdout + w.Close() + os.Stdout = old + var b bytes.Buffer + io.Copy(&b, r) + r.Close() + + commandOutput := b.String() + return commandOutput, err +} diff --git a/cmd/helm/testdata/testcharts/chart-verify-templates/mariner.yaml b/cmd/helm/testdata/testcharts/chart-verify-templates/mariner.yaml new file mode 100644 index 000000000..66ad27486 --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-verify-templates/mariner.yaml @@ -0,0 +1,5 @@ +--- +# Source: frobnitz/charts/mariner/templates/placeholder.tpl +# This is a placeholder. + +Goodbye moon diff --git a/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_kube_service.yaml b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_kube_service.yaml new file mode 100644 index 000000000..ffe0c0cfe --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_kube_service.yaml @@ -0,0 +1,58 @@ +--- +# Source: subchart1/charts/subcharta/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subcharta + labels: + chart: "subcharta-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: apache + selector: + app: subcharta +--- +# Source: subchart1/charts/subchartb/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchartb + labels: + chart: "subchartb-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchartb +--- +# Source: subchart1/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchart1 + labels: + chart: "subchart1-0.1.0" + namespace: "jx" + release-name: "release-name" + release-is-upgrade: "false" + release-is-install: "true" + kube-version/major: "1" + kube-version/minor: "6" + kube-version/gitversion: "v1.6.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchart1 diff --git a/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_service.yaml b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_service.yaml new file mode 100644 index 000000000..b80439b9d --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_service.yaml @@ -0,0 +1,58 @@ +--- +# Source: subchart1/charts/subcharta/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subcharta + labels: + chart: "subcharta-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: apache + selector: + app: subcharta +--- +# Source: subchart1/charts/subchartb/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchartb + labels: + chart: "subchartb-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchartb +--- +# Source: subchart1/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchart1 + labels: + chart: "subchart1-0.1.0" + namespace: "jx" + release-name: "release-name" + release-is-upgrade: "false" + release-is-install: "true" + kube-version/major: "1" + kube-version/minor: "9" + kube-version/gitversion: "v1.9.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchart1 diff --git a/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-namespace_service.yaml b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-namespace_service.yaml new file mode 100644 index 000000000..ba0ff0fd3 --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-namespace_service.yaml @@ -0,0 +1,58 @@ +--- +# Source: subchart1/charts/subcharta/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subcharta + labels: + chart: "subcharta-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: apache + selector: + app: subcharta +--- +# Source: subchart1/charts/subchartb/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchartb + labels: + chart: "subchartb-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchartb +--- +# Source: subchart1/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchart1 + labels: + chart: "subchart1-0.1.0" + namespace: "test" + release-name: "release-name" + release-is-upgrade: "false" + release-is-install: "true" + kube-version/major: "1" + kube-version/minor: "9" + kube-version/gitversion: "v1.9.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchart1 diff --git a/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-release-install_service.yaml b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-release-install_service.yaml new file mode 100644 index 000000000..b80439b9d --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-release-install_service.yaml @@ -0,0 +1,58 @@ +--- +# Source: subchart1/charts/subcharta/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subcharta + labels: + chart: "subcharta-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: apache + selector: + app: subcharta +--- +# Source: subchart1/charts/subchartb/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchartb + labels: + chart: "subchartb-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchartb +--- +# Source: subchart1/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchart1 + labels: + chart: "subchart1-0.1.0" + namespace: "jx" + release-name: "release-name" + release-is-upgrade: "false" + release-is-install: "true" + kube-version/major: "1" + kube-version/minor: "9" + kube-version/gitversion: "v1.9.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchart1 diff --git a/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-release-periods_service.yaml b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-release-periods_service.yaml new file mode 100644 index 000000000..2eaa70ae6 --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-release-periods_service.yaml @@ -0,0 +1,58 @@ +--- +# Source: subchart1/charts/subcharta/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subcharta + labels: + chart: "subcharta-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: apache + selector: + app: subcharta +--- +# Source: subchart1/charts/subchartb/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchartb + labels: + chart: "subchartb-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchartb +--- +# Source: subchart1/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchart1 + labels: + chart: "subchart1-0.1.0" + namespace: "jx" + release-name: "foo.bar" + release-is-upgrade: "false" + release-is-install: "true" + kube-version/major: "1" + kube-version/minor: "9" + kube-version/gitversion: "v1.9.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchart1 diff --git a/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-release-upgrade_service.yaml b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-release-upgrade_service.yaml new file mode 100644 index 000000000..e4a17bb07 --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-release-upgrade_service.yaml @@ -0,0 +1,58 @@ +--- +# Source: subchart1/charts/subcharta/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subcharta + labels: + chart: "subcharta-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: apache + selector: + app: subcharta +--- +# Source: subchart1/charts/subchartb/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchartb + labels: + chart: "subchartb-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchartb +--- +# Source: subchart1/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchart1 + labels: + chart: "subchart1-0.1.0" + namespace: "jx" + release-name: "release-name" + release-is-upgrade: "true" + release-is-install: "false" + kube-version/major: "1" + kube-version/minor: "9" + kube-version/gitversion: "v1.9.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchart1 diff --git a/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-release_service.yaml b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-release_service.yaml new file mode 100644 index 000000000..35f4ba50d --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_set-release_service.yaml @@ -0,0 +1,58 @@ +--- +# Source: subchart1/charts/subcharta/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subcharta + labels: + chart: "subcharta-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: apache + selector: + app: subcharta +--- +# Source: subchart1/charts/subchartb/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchartb + labels: + chart: "subchartb-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchartb +--- +# Source: subchart1/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchart1 + labels: + chart: "subchart1-0.1.0" + namespace: "jx" + release-name: "test" + release-is-upgrade: "false" + release-is-install: "true" + kube-version/major: "1" + kube-version/minor: "9" + kube-version/gitversion: "v1.9.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchart1 diff --git a/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_subchart1_NOTES.yaml b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_subchart1_NOTES.yaml new file mode 100644 index 000000000..40ce393b4 --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_subchart1_NOTES.yaml @@ -0,0 +1,61 @@ +--- +# Source: subchart1/charts/subcharta/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subcharta + labels: + chart: "subcharta-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: apache + selector: + app: subcharta +--- +# Source: subchart1/charts/subchartb/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchartb + labels: + chart: "subchartb-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchartb +--- +# Source: subchart1/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchart1 + labels: + chart: "subchart1-0.1.0" + namespace: "jx" + release-name: "release-name" + release-is-upgrade: "false" + release-is-install: "true" + kube-version/major: "1" + kube-version/minor: "9" + kube-version/gitversion: "v1.9.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchart1 +--- +# Source: subchart1/templates/NOTES.txt +Sample notes for subchart1 \ No newline at end of file diff --git a/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_subchart1_service.yaml b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_subchart1_service.yaml new file mode 100644 index 000000000..54f90986c --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_subchart1_service.yaml @@ -0,0 +1,24 @@ +--- +# Source: subchart1/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchart1 + labels: + chart: "subchart1-0.1.0" + namespace: "jx" + release-name: "release-name" + release-is-upgrade: "false" + release-is-install: "true" + kube-version/major: "1" + kube-version/minor: "9" + kube-version/gitversion: "v1.9.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: apache + selector: + app: subchart1 diff --git a/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_subcharta_foobar_service.yaml b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_subcharta_foobar_service.yaml new file mode 100644 index 000000000..2b62dfdc9 --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_subcharta_foobar_service.yaml @@ -0,0 +1,17 @@ +--- +# Source: subchart1/charts/subcharta/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subcharta + labels: + chart: "subcharta-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: foobar + selector: + app: subcharta diff --git a/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_template_service.yaml b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_template_service.yaml new file mode 100644 index 000000000..feaa8d671 --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_template_service.yaml @@ -0,0 +1,58 @@ +--- +# Source: subchart1/charts/subcharta/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subcharta + labels: + chart: "subcharta-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: apache + selector: + app: subcharta +--- +# Source: subchart1/charts/subchartb/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchartb + labels: + chart: "subchartb-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchartb +--- +# Source: subchart1/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchart1 + labels: + chart: "subchart1-0.1.0" + namespace: "jx" + release-name: "foobar-abc-baz" + release-is-upgrade: "false" + release-is-install: "true" + kube-version/major: "1" + kube-version/minor: "9" + kube-version/gitversion: "v1.9.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchart1 diff --git a/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_values_service.yaml b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_values_service.yaml new file mode 100644 index 000000000..030a0f160 --- /dev/null +++ b/cmd/helm/testdata/testcharts/chart-verify-templates/subpop_values_service.yaml @@ -0,0 +1,58 @@ +--- +# Source: subchart1/charts/subcharta/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subcharta + labels: + chart: "subcharta-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: apache + selector: + app: subcharta +--- +# Source: subchart1/charts/subchartb/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchartb + labels: + chart: "subchartb-0.1.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: nginx + selector: + app: subchartb +--- +# Source: subchart1/templates/service.yaml +apiVersion: v1 +kind: Service +metadata: + name: subchart1 + labels: + chart: "subchart1-0.1.0" + namespace: "jx" + release-name: "release-name" + release-is-upgrade: "false" + release-is-install: "true" + kube-version/major: "1" + kube-version/minor: "9" + kube-version/gitversion: "v1.9.0" +spec: + type: ClusterIP + ports: + - port: 80 + targetPort: 80 + protocol: TCP + name: apache + selector: + app: subchart1