From bcc3acd9fe46fb9b227118c70d8db5c2c67bd819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A1=E7=8E=AE=E6=96=87?= Date: Wed, 23 Sep 2026 23:58:30 +0800 Subject: [PATCH] fix(action): preserve trailing newlines when writing manifests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Manifest splitting preserves trailing newlines so post-renderers can parse block scalars correctly. The output writers still append another newline, changing |+ and >+ values in installed resources as well as adding blank lines to rendered YAML. Trim one newline before the format string adds it back. This preserves all existing newlines and adds one only if missing. Document separators need a preceding line break; adding a missing newline also matches how Kubernetes' YAMLOrJSONDecoder handles an unterminated final line. Apply this rule to renderResources and its output-dir writer, leaving manifest splitting and post-renderer parsing unchanged. Test all six block scalar indicators with zero, one and two authored newlines, in final and non-final positions. Check exact output bytes and decoded values for both buffer and file output, including Kubernetes' EOF normalization. Signed-off-by: 胡玮文 --- pkg/action/action.go | 18 +++-- pkg/action/action_test.go | 78 +++++++++++++++++-- pkg/action/install.go | 2 +- pkg/action/testdata/rbac.txt | 2 - .../install-dry-run-with-secret-hidden.txt | 1 - .../output/install-dry-run-with-secret.txt | 2 - pkg/cmd/testdata/output/issue-9027.txt | 1 - pkg/cmd/testdata/output/object-order.txt | 13 ---- .../output/template-name-template.txt | 5 -- pkg/cmd/testdata/output/template-set.txt | 5 -- .../output/template-show-only-glob.txt | 2 - .../output/template-show-only-multiple.txt | 1 - .../testdata/output/template-skip-tests.txt | 5 -- .../output/template-subchart-cm-set-file.txt | 5 -- .../output/template-subchart-cm-set.txt | 5 -- .../testdata/output/template-subchart-cm.txt | 5 -- .../testdata/output/template-values-files.txt | 5 -- .../output/template-with-api-version.txt | 5 -- .../testdata/output/template-with-crds.txt | 6 -- .../output/template-with-kube-version.txt | 5 -- pkg/cmd/testdata/output/template.txt | 5 -- 21 files changed, 86 insertions(+), 90 deletions(-) diff --git a/pkg/action/action.go b/pkg/action/action.go index 015fa2736..90b57c97e 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -270,6 +270,14 @@ func splitAndDeannotate(postrendered, fallbackPrefix string) (map[string]string, return reconstructed, nil } +func appendSourceManifest(b []byte, source, body string) []byte { + // Preserve existing trailing newlines: block scalars may retain them. + // Adding a missing newline can change a scalar's value, but document + // separators require a line break and Kubernetes' YAMLOrJSONDecoder + // also adds one to an unterminated final line. + return fmt.Appendf(b, "---\n# Source: %s\n%s\n", source, strings.TrimSuffix(body, "\n")) +} + // renderResources renders the templates in a chart // // TODO: This function is badly in need of a refactor. @@ -355,7 +363,7 @@ func (cfg *Configuration) renderResources(ctx context.Context, ch *chart.Chart, if strings.TrimSpace(content) == "" { continue } - b = fmt.Appendf(b, "---\n# Source: %s\n%s\n", name, content) + b = appendSourceManifest(b, name, content) } return hs, b, "", err } @@ -473,7 +481,7 @@ func (cfg *Configuration) renderResources(ctx context.Context, ch *chart.Chart, if strings.TrimSpace(content) == "" { continue } - b = fmt.Appendf(b, "---\n# Source: %s\n%s\n", name, content) + b = appendSourceManifest(b, name, content) } return hs, b, "", err } @@ -484,7 +492,7 @@ func (cfg *Configuration) renderResources(ctx context.Context, ch *chart.Chart, if includeCrds { for _, crd := range ch.CRDObjects() { if outputDir == "" { - b = fmt.Appendf(b, "---\n# Source: %s\n%s\n", crd.Filename, string(crd.File.Data)) + b = appendSourceManifest(b, crd.Filename, string(crd.File.Data)) } else { err = writeToFile(outputDir, crd.Filename, string(crd.File.Data), fileWritten[crd.Filename]) if err != nil { @@ -498,9 +506,9 @@ func (cfg *Configuration) renderResources(ctx context.Context, ch *chart.Chart, for _, m := range manifests { if outputDir == "" { if hideSecret && m.Head.Kind == "Secret" && m.Head.Version == "v1" { - b = fmt.Appendf(b, "---\n# Source: %s\n# HIDDEN: The Secret output has been suppressed\n", m.Name) + b = appendSourceManifest(b, m.Name, "# HIDDEN: The Secret output has been suppressed\n") } else { - b = fmt.Appendf(b, "---\n# Source: %s\n%s\n", m.Name, m.Content) + b = appendSourceManifest(b, m.Name, m.Content) } } else { newDir := outputDir diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index d4294f00a..58cc2d4d1 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -22,12 +22,16 @@ import ( "fmt" "io" "log/slog" + "os" + "path/filepath" "strings" "testing" "time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "go.yaml.in/yaml/v3" + k8syaml "k8s.io/apimachinery/pkg/util/yaml" fakeclientset "k8s.io/client-go/kubernetes/fake" "helm.sh/helm/v4/internal/logging" @@ -1826,15 +1830,12 @@ func TestRenderResources_PostRenderer_Success(t *testing.T) { expectedBuf := `--- # Source: yellow/templates/foodpie foodpie: world - --- # Source: yellow/templates/with-partials yellow: Earth - --- # Source: yellow/templates/yellow yellow: world - ` expectedHook := `kind: ConfigMap metadata: @@ -1946,17 +1947,14 @@ func TestRenderResources_PostRenderer_Integration(t *testing.T) { # Source: hello/templates/goodbye goodbye: world color: blue - --- # Source: hello/templates/hello hello: world color: blue - --- # Source: hello/templates/with-partials hello: Earth color: blue - ` assert.Contains(t, output, "color: blue") assert.Equal(t, 3, strings.Count(output, "color: blue")) @@ -2276,6 +2274,74 @@ metadata: assert.ErrorContains(t, err, "bogus") } +func TestRenderResources_BlockScalarChomping(t *testing.T) { + tests := []struct { + name string + indicator string + value string + wantNewlines [3]int // indexed by the number of authored trailing newlines + }{ + {"literal_clip", "|", "line1\nline2", [3]int{1, 1, 1}}, + {"literal_strip", "|-", "line1\nline2", [3]int{0, 0, 0}}, + {"literal_keep", "|+", "line1\nline2", [3]int{1, 1, 2}}, + {"folded_clip", ">", "line1 line2", [3]int{1, 1, 1}}, + {"folded_strip", ">-", "line1 line2", [3]int{0, 0, 0}}, + {"folded_keep", ">+", "line1 line2", [3]int{1, 1, 2}}, + } + for _, tc := range tests { + for trailing := range 3 { + for _, output := range []string{"buffer", "output-dir"} { + t.Run(fmt.Sprintf("%s/%d_newlines/%s", tc.name, trailing, output), func(t *testing.T) { + var files []*common.File + var wantOutput strings.Builder + for _, name := range []string{"first", "last"} { + body := fmt.Sprintf("apiVersion: v1\nkind: ConfigMap\nmetadata:\n name: %s\ndata:\n cfg: %s\n line1\n line2", name, tc.indicator) + path := "templates/" + name + ".yaml" + files = append(files, &common.File{Name: path, Data: []byte(body + strings.Repeat("\n", trailing))}) + fmt.Fprintf(&wantOutput, "---\n# Source: hello/%s\n%s%s", path, body, strings.Repeat("\n", max(1, trailing))) + } + + outputDir := "" + if output == "output-dir" { + outputDir = t.TempDir() + } + cfg := actionConfigFixture(t) + _, rendered, _, err := cfg.renderResources( + t.Context(), buildChartWithTemplates(files), nil, "test-release", outputDir, false, false, false, + nil, false, false, false, PostRenderStrategyCombined, + ) + require.NoError(t, err) + if outputDir != "" { + assert.Empty(t, rendered) + for _, file := range files { + data, err := os.ReadFile(filepath.Join(outputDir, "hello", file.Name)) + require.NoError(t, err) + rendered = append(rendered, data...) + } + } + assert.Equal(t, wantOutput.String(), string(rendered)) + + var cm struct { + Data map[string]string `json:"data" yaml:"data"` + } + wantValue := tc.value + strings.Repeat("\n", tc.wantNewlines[trailing]) + // Kubernetes also normalizes a missing newline in a standalone document. + require.NoError(t, k8syaml.NewYAMLOrJSONDecoder(bytes.NewReader(files[0].Data), 4096).Decode(&cm)) + assert.Equal(t, wantValue, cm.Data["cfg"]) + + // Decode the whole stream without Kubernetes' implicit EOF newline. + decoder := yaml.NewDecoder(bytes.NewReader(rendered)) + for range 2 { + require.NoError(t, decoder.Decode(&cm)) + assert.Equal(t, wantValue, cm.Data["cfg"]) + } + require.ErrorIs(t, decoder.Decode(&cm), io.EOF) + }) + } + } + } +} + func TestDetermineReleaseSSAApplyMethod(t *testing.T) { assert.Equal(t, release.ApplyMethodClientSideApply, determineReleaseSSApplyMethod(false)) assert.Equal(t, release.ApplyMethodServerSideApply, determineReleaseSSApplyMethod(true)) diff --git a/pkg/action/install.go b/pkg/action/install.go index c2c054968..5e6b08aff 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -730,7 +730,7 @@ func writeToFile(outputDir, name, data string, appendData bool) error { defer f.Close() - _, err = fmt.Fprintf(f, "---\n# Source: %s\n%s\n", name, data) + _, err = fmt.Fprintf(f, "---\n# Source: %s\n%s\n", name, strings.TrimSuffix(data, "\n")) if err != nil { return err } diff --git a/pkg/action/testdata/rbac.txt b/pkg/action/testdata/rbac.txt index c8c2fd66e..12f102137 100644 --- a/pkg/action/testdata/rbac.txt +++ b/pkg/action/testdata/rbac.txt @@ -9,7 +9,6 @@ rules: resources: ["pods", "pods/exec", "pods/log"] verbs: ["*"] - --- # Source: hello/templates/rbac apiVersion: rbac.authorization.k8s.io/v1 @@ -25,4 +24,3 @@ subjects: - kind: ServiceAccount name: schedule-agents namespace: spaced - diff --git a/pkg/cmd/testdata/output/install-dry-run-with-secret-hidden.txt b/pkg/cmd/testdata/output/install-dry-run-with-secret-hidden.txt index c2219d8c4..eb770967f 100644 --- a/pkg/cmd/testdata/output/install-dry-run-with-secret-hidden.txt +++ b/pkg/cmd/testdata/output/install-dry-run-with-secret-hidden.txt @@ -19,4 +19,3 @@ metadata: data: foo: bar - diff --git a/pkg/cmd/testdata/output/install-dry-run-with-secret.txt b/pkg/cmd/testdata/output/install-dry-run-with-secret.txt index 62bd78018..d22c1437f 100644 --- a/pkg/cmd/testdata/output/install-dry-run-with-secret.txt +++ b/pkg/cmd/testdata/output/install-dry-run-with-secret.txt @@ -15,7 +15,6 @@ metadata: name: test-secret stringData: foo: bar - --- # Source: chart-with-secret/templates/configmap.yaml apiVersion: v1 @@ -25,4 +24,3 @@ metadata: data: foo: bar - diff --git a/pkg/cmd/testdata/output/issue-9027.txt b/pkg/cmd/testdata/output/issue-9027.txt index f43032499..1227336e4 100644 --- a/pkg/cmd/testdata/output/issue-9027.txt +++ b/pkg/cmd/testdata/output/issue-9027.txt @@ -15,7 +15,6 @@ hash: key4: 4 key5: 5 key6: 6 - --- # Source: issue-9027/templates/values.yaml global: diff --git a/pkg/cmd/testdata/output/object-order.txt b/pkg/cmd/testdata/output/object-order.txt index 96e3ba053..8ca93377c 100644 --- a/pkg/cmd/testdata/output/object-order.txt +++ b/pkg/cmd/testdata/output/object-order.txt @@ -11,7 +11,6 @@ spec: - Egress - Ingress - --- # Source: object-order/templates/01-a.yml # 2 @@ -25,7 +24,6 @@ spec: - Egress - Ingress - --- # Source: object-order/templates/01-a.yml # 3 @@ -39,7 +37,6 @@ spec: - Egress - Ingress - --- # Source: object-order/templates/02-b.yml # 5 @@ -53,7 +50,6 @@ spec: - Egress - Ingress - --- # Source: object-order/templates/02-b.yml # 7 @@ -67,7 +63,6 @@ spec: - Egress - Ingress - --- # Source: object-order/templates/02-b.yml # 8 @@ -81,7 +76,6 @@ spec: - Egress - Ingress - --- # Source: object-order/templates/02-b.yml # 9 @@ -95,7 +89,6 @@ spec: - Egress - Ingress - --- # Source: object-order/templates/02-b.yml # 10 @@ -109,7 +102,6 @@ spec: - Egress - Ingress - --- # Source: object-order/templates/02-b.yml # 11 @@ -123,7 +115,6 @@ spec: - Egress - Ingress - --- # Source: object-order/templates/02-b.yml # 12 @@ -137,7 +128,6 @@ spec: - Egress - Ingress - --- # Source: object-order/templates/02-b.yml # 13 @@ -151,7 +141,6 @@ spec: - Egress - Ingress - --- # Source: object-order/templates/02-b.yml # 14 @@ -165,7 +154,6 @@ spec: - Egress - Ingress - --- # Source: object-order/templates/02-b.yml # 15 (11th object within 02-b.yml, in order to test `SplitManifests` which assigns `manifest-10` @@ -179,7 +167,6 @@ spec: policyTypes: - Egress - Ingress - --- # Source: object-order/templates/01-a.yml # 4 (Deployment should come after all NetworkPolicy manifests, since 'helm template' outputs in install order) diff --git a/pkg/cmd/testdata/output/template-name-template.txt b/pkg/cmd/testdata/output/template-name-template.txt index b1077012e..485b2f59c 100644 --- a/pkg/cmd/testdata/output/template-name-template.txt +++ b/pkg/cmd/testdata/output/template-name-template.txt @@ -4,7 +4,6 @@ apiVersion: v1 kind: ServiceAccount metadata: name: subchart-sa - --- # Source: subchart/templates/subdir/role.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -15,7 +14,6 @@ rules: - apiGroups: [""] resources: ["pods"] verbs: ["get","list","watch"] - --- # Source: subchart/templates/subdir/rolebinding.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -30,7 +28,6 @@ subjects: - kind: ServiceAccount name: subchart-sa namespace: default - --- # Source: subchart/charts/subcharta/templates/service.yaml apiVersion: v1 @@ -48,7 +45,6 @@ spec: name: apache selector: app.kubernetes.io/name: subcharta - --- # Source: subchart/charts/subchartb/templates/service.yaml apiVersion: v1 @@ -66,7 +62,6 @@ spec: name: nginx selector: app.kubernetes.io/name: subchartb - --- # Source: subchart/templates/service.yaml apiVersion: v1 diff --git a/pkg/cmd/testdata/output/template-set.txt b/pkg/cmd/testdata/output/template-set.txt index 1ecb8707b..cc14c2b7e 100644 --- a/pkg/cmd/testdata/output/template-set.txt +++ b/pkg/cmd/testdata/output/template-set.txt @@ -4,7 +4,6 @@ apiVersion: v1 kind: ServiceAccount metadata: name: subchart-sa - --- # Source: subchart/templates/subdir/role.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -15,7 +14,6 @@ rules: - apiGroups: [""] resources: ["pods"] verbs: ["get","list","watch"] - --- # Source: subchart/templates/subdir/rolebinding.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -30,7 +28,6 @@ subjects: - kind: ServiceAccount name: subchart-sa namespace: default - --- # Source: subchart/charts/subcharta/templates/service.yaml apiVersion: v1 @@ -48,7 +45,6 @@ spec: name: apache selector: app.kubernetes.io/name: subcharta - --- # Source: subchart/charts/subchartb/templates/service.yaml apiVersion: v1 @@ -66,7 +62,6 @@ spec: name: nginx selector: app.kubernetes.io/name: subchartb - --- # Source: subchart/templates/service.yaml apiVersion: v1 diff --git a/pkg/cmd/testdata/output/template-show-only-glob.txt b/pkg/cmd/testdata/output/template-show-only-glob.txt index 160f08a06..28bc465b2 100644 --- a/pkg/cmd/testdata/output/template-show-only-glob.txt +++ b/pkg/cmd/testdata/output/template-show-only-glob.txt @@ -9,7 +9,6 @@ rules: resources: ["pods"] verbs: ["get","list","watch"] - --- # Source: subchart/templates/subdir/rolebinding.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -25,4 +24,3 @@ subjects: name: subchart-sa namespace: default - diff --git a/pkg/cmd/testdata/output/template-show-only-multiple.txt b/pkg/cmd/testdata/output/template-show-only-multiple.txt index 3f9aa6f2f..97f995286 100644 --- a/pkg/cmd/testdata/output/template-show-only-multiple.txt +++ b/pkg/cmd/testdata/output/template-show-only-multiple.txt @@ -38,4 +38,3 @@ spec: selector: app.kubernetes.io/name: subcharta - diff --git a/pkg/cmd/testdata/output/template-skip-tests.txt b/pkg/cmd/testdata/output/template-skip-tests.txt index 4c5af8df3..5c907b563 100644 --- a/pkg/cmd/testdata/output/template-skip-tests.txt +++ b/pkg/cmd/testdata/output/template-skip-tests.txt @@ -4,7 +4,6 @@ apiVersion: v1 kind: ServiceAccount metadata: name: subchart-sa - --- # Source: subchart/templates/subdir/role.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -15,7 +14,6 @@ rules: - apiGroups: [""] resources: ["pods"] verbs: ["get","list","watch"] - --- # Source: subchart/templates/subdir/rolebinding.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -30,7 +28,6 @@ subjects: - kind: ServiceAccount name: subchart-sa namespace: default - --- # Source: subchart/charts/subcharta/templates/service.yaml apiVersion: v1 @@ -48,7 +45,6 @@ spec: name: apache selector: app.kubernetes.io/name: subcharta - --- # Source: subchart/charts/subchartb/templates/service.yaml apiVersion: v1 @@ -66,7 +62,6 @@ spec: name: nginx selector: app.kubernetes.io/name: subchartb - --- # Source: subchart/templates/service.yaml apiVersion: v1 diff --git a/pkg/cmd/testdata/output/template-subchart-cm-set-file.txt b/pkg/cmd/testdata/output/template-subchart-cm-set-file.txt index 227d05903..67fda94c7 100644 --- a/pkg/cmd/testdata/output/template-subchart-cm-set-file.txt +++ b/pkg/cmd/testdata/output/template-subchart-cm-set-file.txt @@ -4,7 +4,6 @@ apiVersion: v1 kind: ServiceAccount metadata: name: subchart-sa - --- # Source: subchart/templates/subdir/configmap.yaml apiVersion: v1 @@ -23,7 +22,6 @@ rules: - apiGroups: [""] resources: ["pods"] verbs: ["get","list","watch"] - --- # Source: subchart/templates/subdir/rolebinding.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -38,7 +36,6 @@ subjects: - kind: ServiceAccount name: subchart-sa namespace: default - --- # Source: subchart/charts/subcharta/templates/service.yaml apiVersion: v1 @@ -56,7 +53,6 @@ spec: name: apache selector: app.kubernetes.io/name: subcharta - --- # Source: subchart/charts/subchartb/templates/service.yaml apiVersion: v1 @@ -74,7 +70,6 @@ spec: name: nginx selector: app.kubernetes.io/name: subchartb - --- # Source: subchart/templates/service.yaml apiVersion: v1 diff --git a/pkg/cmd/testdata/output/template-subchart-cm-set.txt b/pkg/cmd/testdata/output/template-subchart-cm-set.txt index dd8be4db9..a280e4466 100644 --- a/pkg/cmd/testdata/output/template-subchart-cm-set.txt +++ b/pkg/cmd/testdata/output/template-subchart-cm-set.txt @@ -4,7 +4,6 @@ apiVersion: v1 kind: ServiceAccount metadata: name: subchart-sa - --- # Source: subchart/templates/subdir/configmap.yaml apiVersion: v1 @@ -23,7 +22,6 @@ rules: - apiGroups: [""] resources: ["pods"] verbs: ["get","list","watch"] - --- # Source: subchart/templates/subdir/rolebinding.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -38,7 +36,6 @@ subjects: - kind: ServiceAccount name: subchart-sa namespace: default - --- # Source: subchart/charts/subcharta/templates/service.yaml apiVersion: v1 @@ -56,7 +53,6 @@ spec: name: apache selector: app.kubernetes.io/name: subcharta - --- # Source: subchart/charts/subchartb/templates/service.yaml apiVersion: v1 @@ -74,7 +70,6 @@ spec: name: nginx selector: app.kubernetes.io/name: subchartb - --- # Source: subchart/templates/service.yaml apiVersion: v1 diff --git a/pkg/cmd/testdata/output/template-subchart-cm.txt b/pkg/cmd/testdata/output/template-subchart-cm.txt index c4600a798..5338e8e0e 100644 --- a/pkg/cmd/testdata/output/template-subchart-cm.txt +++ b/pkg/cmd/testdata/output/template-subchart-cm.txt @@ -4,7 +4,6 @@ apiVersion: v1 kind: ServiceAccount metadata: name: subchart-sa - --- # Source: subchart/templates/subdir/configmap.yaml apiVersion: v1 @@ -23,7 +22,6 @@ rules: - apiGroups: [""] resources: ["pods"] verbs: ["get","list","watch"] - --- # Source: subchart/templates/subdir/rolebinding.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -38,7 +36,6 @@ subjects: - kind: ServiceAccount name: subchart-sa namespace: default - --- # Source: subchart/charts/subcharta/templates/service.yaml apiVersion: v1 @@ -56,7 +53,6 @@ spec: name: apache selector: app.kubernetes.io/name: subcharta - --- # Source: subchart/charts/subchartb/templates/service.yaml apiVersion: v1 @@ -74,7 +70,6 @@ spec: name: nginx selector: app.kubernetes.io/name: subchartb - --- # Source: subchart/templates/service.yaml apiVersion: v1 diff --git a/pkg/cmd/testdata/output/template-values-files.txt b/pkg/cmd/testdata/output/template-values-files.txt index 1ecb8707b..cc14c2b7e 100644 --- a/pkg/cmd/testdata/output/template-values-files.txt +++ b/pkg/cmd/testdata/output/template-values-files.txt @@ -4,7 +4,6 @@ apiVersion: v1 kind: ServiceAccount metadata: name: subchart-sa - --- # Source: subchart/templates/subdir/role.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -15,7 +14,6 @@ rules: - apiGroups: [""] resources: ["pods"] verbs: ["get","list","watch"] - --- # Source: subchart/templates/subdir/rolebinding.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -30,7 +28,6 @@ subjects: - kind: ServiceAccount name: subchart-sa namespace: default - --- # Source: subchart/charts/subcharta/templates/service.yaml apiVersion: v1 @@ -48,7 +45,6 @@ spec: name: apache selector: app.kubernetes.io/name: subcharta - --- # Source: subchart/charts/subchartb/templates/service.yaml apiVersion: v1 @@ -66,7 +62,6 @@ spec: name: nginx selector: app.kubernetes.io/name: subchartb - --- # Source: subchart/templates/service.yaml apiVersion: v1 diff --git a/pkg/cmd/testdata/output/template-with-api-version.txt b/pkg/cmd/testdata/output/template-with-api-version.txt index ae726e624..81346ff91 100644 --- a/pkg/cmd/testdata/output/template-with-api-version.txt +++ b/pkg/cmd/testdata/output/template-with-api-version.txt @@ -4,7 +4,6 @@ apiVersion: v1 kind: ServiceAccount metadata: name: subchart-sa - --- # Source: subchart/templates/subdir/role.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -15,7 +14,6 @@ rules: - apiGroups: [""] resources: ["pods"] verbs: ["get","list","watch"] - --- # Source: subchart/templates/subdir/rolebinding.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -30,7 +28,6 @@ subjects: - kind: ServiceAccount name: subchart-sa namespace: default - --- # Source: subchart/charts/subcharta/templates/service.yaml apiVersion: v1 @@ -48,7 +45,6 @@ spec: name: apache selector: app.kubernetes.io/name: subcharta - --- # Source: subchart/charts/subchartb/templates/service.yaml apiVersion: v1 @@ -66,7 +62,6 @@ spec: name: nginx selector: app.kubernetes.io/name: subchartb - --- # Source: subchart/templates/service.yaml apiVersion: v1 diff --git a/pkg/cmd/testdata/output/template-with-crds.txt b/pkg/cmd/testdata/output/template-with-crds.txt index 1d63265ec..b17088b76 100644 --- a/pkg/cmd/testdata/output/template-with-crds.txt +++ b/pkg/cmd/testdata/output/template-with-crds.txt @@ -14,14 +14,12 @@ spec: shortNames: - tc singular: authconfig - --- # Source: subchart/templates/subdir/serviceaccount.yaml apiVersion: v1 kind: ServiceAccount metadata: name: subchart-sa - --- # Source: subchart/templates/subdir/role.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -32,7 +30,6 @@ rules: - apiGroups: [""] resources: ["pods"] verbs: ["get","list","watch"] - --- # Source: subchart/templates/subdir/rolebinding.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -47,7 +44,6 @@ subjects: - kind: ServiceAccount name: subchart-sa namespace: default - --- # Source: subchart/charts/subcharta/templates/service.yaml apiVersion: v1 @@ -65,7 +61,6 @@ spec: name: apache selector: app.kubernetes.io/name: subcharta - --- # Source: subchart/charts/subchartb/templates/service.yaml apiVersion: v1 @@ -83,7 +78,6 @@ spec: name: nginx selector: app.kubernetes.io/name: subchartb - --- # Source: subchart/templates/service.yaml apiVersion: v1 diff --git a/pkg/cmd/testdata/output/template-with-kube-version.txt b/pkg/cmd/testdata/output/template-with-kube-version.txt index 2c42e2e84..e088a9085 100644 --- a/pkg/cmd/testdata/output/template-with-kube-version.txt +++ b/pkg/cmd/testdata/output/template-with-kube-version.txt @@ -4,7 +4,6 @@ apiVersion: v1 kind: ServiceAccount metadata: name: subchart-sa - --- # Source: subchart/templates/subdir/role.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -15,7 +14,6 @@ rules: - apiGroups: [""] resources: ["pods"] verbs: ["get","list","watch"] - --- # Source: subchart/templates/subdir/rolebinding.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -30,7 +28,6 @@ subjects: - kind: ServiceAccount name: subchart-sa namespace: default - --- # Source: subchart/charts/subcharta/templates/service.yaml apiVersion: v1 @@ -48,7 +45,6 @@ spec: name: apache selector: app.kubernetes.io/name: subcharta - --- # Source: subchart/charts/subchartb/templates/service.yaml apiVersion: v1 @@ -66,7 +62,6 @@ spec: name: nginx selector: app.kubernetes.io/name: subchartb - --- # Source: subchart/templates/service.yaml apiVersion: v1 diff --git a/pkg/cmd/testdata/output/template.txt b/pkg/cmd/testdata/output/template.txt index ddbfebe9d..c3f33b919 100644 --- a/pkg/cmd/testdata/output/template.txt +++ b/pkg/cmd/testdata/output/template.txt @@ -4,7 +4,6 @@ apiVersion: v1 kind: ServiceAccount metadata: name: subchart-sa - --- # Source: subchart/templates/subdir/role.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -15,7 +14,6 @@ rules: - apiGroups: [""] resources: ["pods"] verbs: ["get","list","watch"] - --- # Source: subchart/templates/subdir/rolebinding.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -30,7 +28,6 @@ subjects: - kind: ServiceAccount name: subchart-sa namespace: default - --- # Source: subchart/charts/subcharta/templates/service.yaml apiVersion: v1 @@ -48,7 +45,6 @@ spec: name: apache selector: app.kubernetes.io/name: subcharta - --- # Source: subchart/charts/subchartb/templates/service.yaml apiVersion: v1 @@ -66,7 +62,6 @@ spec: name: nginx selector: app.kubernetes.io/name: subchartb - --- # Source: subchart/templates/service.yaml apiVersion: v1