Skip to content

Commit ecf79d9

Browse files
Merge branch 'databus23:master' into structured-diff-list
2 parents d85d71d + 6153341 commit ecf79d9

10 files changed

Lines changed: 174 additions & 71 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
if: "!contains(github.event.head_commit.message, '[ci skip]')"
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v6
17-
- uses: actions/setup-go@v6
16+
- uses: actions/checkout@v7
17+
- uses: actions/setup-go@v7
1818
with:
1919
go-version-file: "go.mod"
2020

@@ -40,7 +40,7 @@ jobs:
4040
os: [ubuntu-latest, macos-latest, windows-latest]
4141
shell: [default]
4242
experimental: [false]
43-
helm-version: [v3.18.6, v3.21.1, v4.2.1]
43+
helm-version: [v3.18.6, v3.21.3, v4.2.3]
4444
include:
4545
- os: windows-latest
4646
shell: wsl
@@ -58,29 +58,29 @@ jobs:
5858
- os: windows-latest
5959
shell: wsl
6060
experimental: false
61-
helm-version: v3.21.1
61+
helm-version: v3.21.3
6262
- os: windows-latest
6363
shell: cygwin
6464
experimental: false
65-
helm-version: v3.21.1
65+
helm-version: v3.21.3
6666
- os: ubuntu-latest
6767
container: alpine
6868
shell: sh
6969
experimental: false
70-
helm-version: v3.21.1
70+
helm-version: v3.21.3
7171
- os: windows-latest
7272
shell: wsl
7373
experimental: false
74-
helm-version: v4.2.1
74+
helm-version: v4.2.3
7575
- os: windows-latest
7676
shell: cygwin
7777
experimental: false
78-
helm-version: v4.2.1
78+
helm-version: v4.2.3
7979
- os: ubuntu-latest
8080
container: alpine
8181
shell: sh
8282
experimental: false
83-
helm-version: v4.2.1
83+
helm-version: v4.2.3
8484

8585
steps:
8686
- name: Disable autocrlf
@@ -89,7 +89,7 @@ jobs:
8989
git config --global core.autocrlf false
9090
git config --global core.eol lf
9191
92-
- uses: actions/checkout@v6
92+
- uses: actions/checkout@v7
9393

9494
- name: Setup Helm
9595
uses: azure/setup-helm@v5
@@ -119,14 +119,14 @@ jobs:
119119
# That's why we cover only 2 Helm minor versions in this matrix.
120120
# See https://github.com/helmfile/helmfile/pull/286#issuecomment-1250161182 for more context.
121121
- helm-version: v3.18.6
122-
- helm-version: v3.21.1
123-
- helm-version: v4.2.1
122+
- helm-version: v3.21.3
123+
- helm-version: v4.2.3
124124
steps:
125125
- uses: helm/kind-action@v1.14.0
126126
with:
127127
cluster_name: kind
128128

129-
- uses: actions/checkout@v6
129+
- uses: actions/checkout@v7
130130

131131
- name: Setup Helm
132132
uses: azure/setup-helm@v5

.github/workflows/lint-sh.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
if: "!contains(github.event.head_commit.message, '[ci skip]')"
1616
continue-on-error: true
1717
steps:
18-
- uses: actions/checkout@v6
18+
- uses: actions/checkout@v7
1919
- uses: luizm/action-sh-checker@v0.10.0
2020
with:
2121
sh_checker_exclude: 'scripts'

.github/workflows/lint.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ jobs:
1515
runs-on: ubuntu-latest
1616
timeout-minutes: 10
1717
steps:
18-
- uses: actions/checkout@v6
19-
- uses: actions/setup-go@v6
18+
- uses: actions/checkout@v7
19+
- uses: actions/setup-go@v7
2020
with:
2121
go-version-file: 'go.mod'
2222
- uses: golangci/golangci-lint-action@v9

.github/workflows/release.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ jobs:
3737
run: echo "flags=--snapshot --skip=sign" >> $GITHUB_ENV
3838
-
3939
name: Checkout
40-
uses: actions/checkout@v6
40+
uses: actions/checkout@v7
4141
with:
4242
fetch-depth: 0
4343
-
4444
name: Set up Go
45-
uses: actions/setup-go@v6
45+
uses: actions/setup-go@v7
4646
with:
4747
go-version-file: 'go.mod'
4848
-
@@ -135,7 +135,7 @@ jobs:
135135
steps:
136136
-
137137
name: Checkout
138-
uses: actions/checkout@v6
138+
uses: actions/checkout@v7
139139
-
140140
name: Test provenance signing with disposable key
141141
run: |

cmd/helm.go

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ func (d *diffCmd) template(isUpgrade bool) ([]byte, error) {
412412
subcmd = "template"
413413

414414
filter = func(s []byte) []byte {
415-
return s
415+
return stripOCIPullProgress(s)
416416
}
417417
}
418418

@@ -494,6 +494,36 @@ func extractManifestFromHelmUpgradeDryRunOutput(s []byte, noHooks bool) []byte {
494494
return r
495495
}
496496

497+
// ociPullProgressRE matches Helm's OCI chart pull progress lines that Helm writes
498+
// to stdout before the rendered manifests when the chart, or one of its subcharts,
499+
// is pulled from an OCI registry.
500+
//
501+
// The lines reported in the wild are "Pulled: ..." and "Digest: ...";
502+
// "Pulling: ..." is matched defensively too.
503+
//
504+
// These lines are emitted at the start of a line and are not valid Kubernetes
505+
// manifests, so they are safe to strip. Top-level manifest keys are
506+
// apiVersion/kind/metadata/spec and never "Pulled", "Digest" or "Pulling";
507+
// any homonymous keys inside a manifest are indented and therefore not matched.
508+
//
509+
// See https://github.com/databus23/helm-diff/issues/1040
510+
var ociPullProgressRE = regexp.MustCompile(`(?m)^(?:Pulled|Digest|Pulling):[^\n]*\n?`)
511+
512+
// stripOCIPullProgress removes Helm's OCI chart pull progress output that leaks
513+
// into the rendered manifest buffer when the chart (or a subchart) is pulled
514+
// from an OCI registry.
515+
//
516+
// Without this, the progress lines (e.g. "Pulled: ...", "Digest: ...") are
517+
// parsed as a YAML document lacking a Kind and break the downstream three-way
518+
// merge / kubeclient.Build():
519+
//
520+
// unable to decode "": Object 'Kind' is missing in '{"Digest":"...","Pulled":"..."}'
521+
//
522+
// See https://github.com/databus23/helm-diff/issues/1040
523+
func stripOCIPullProgress(s []byte) []byte {
524+
return ociPullProgressRE.ReplaceAll(s, []byte(""))
525+
}
526+
497527
// serverSideFlags returns the --server-side flag(s) to forward to helm.
498528
//
499529
// The flag is Helm v4 only:

cmd/helm_test.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,78 @@ import (
88
"github.com/google/go-cmp/cmp"
99
)
1010

11+
func TestStripOCIPullProgress(t *testing.T) {
12+
manifest := `---
13+
# Source: karpenter/templates/cm.yaml
14+
apiVersion: v1
15+
kind: ConfigMap
16+
metadata:
17+
name: karpenter
18+
namespace: karpenter
19+
data:
20+
Pulled: preserved
21+
Digest: preserved
22+
---
23+
# Source: karpenter/templates/deployment.yaml
24+
apiVersion: apps/v1
25+
kind: Deployment
26+
metadata:
27+
name: karpenter
28+
namespace: karpenter
29+
`
30+
31+
cases := []struct {
32+
name string
33+
in string
34+
want string
35+
}{
36+
{
37+
name: "strips OCI pull progress prepended to manifests",
38+
in: "Pulled: public.ecr.aws/karpenter/karpenter:1.9.0\n" +
39+
"Digest: sha256:8e3952caafd208cb888fbf97467cd04a4a024a3fba64c84af73039040cc6a371\n" +
40+
manifest,
41+
want: manifest,
42+
},
43+
{
44+
name: "strips Pulling/Pulled/Digest progress lines",
45+
in: "Pulling: public.ecr.aws/karpenter/karpenter:1.9.0\n" +
46+
"Pulled: public.ecr.aws/karpenter/karpenter:1.9.0\n" +
47+
"Digest: sha256:abc123\n" +
48+
manifest,
49+
want: manifest,
50+
},
51+
{
52+
name: "does not modify output without OCI progress",
53+
in: manifest,
54+
want: manifest,
55+
},
56+
{
57+
name: "preserves indented Pulled/Digest keys inside manifests",
58+
in: manifest,
59+
want: manifest,
60+
},
61+
{
62+
name: "strips OCI progress even with no trailing manifests",
63+
in: "Pulled: registry.example.com/chart:1.0.0\nDigest: sha256:deadbeef\n",
64+
want: "",
65+
},
66+
{
67+
name: "returns empty for empty input",
68+
in: "",
69+
want: "",
70+
},
71+
}
72+
73+
for _, tc := range cases {
74+
t.Run(tc.name, func(t *testing.T) {
75+
got := stripOCIPullProgress([]byte(tc.in))
76+
if d := cmp.Diff(tc.want, string(got)); d != "" {
77+
t.Errorf("unexpected diff: %s", d)
78+
}
79+
})
80+
}
81+
}
82+
1183
type dryRunFlagsConfig struct {
1284
isHelmV4 bool
1385
supportsDryRunLookup bool

cmd/local.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,5 +250,6 @@ func (l *local) renderChart(chartPath string) ([]byte, error) {
250250
helmBin = "helm"
251251
}
252252
cmd := exec.Command(helmBin, args...)
253-
return outputWithRichError(cmd)
253+
out, err := outputWithRichError(cmd)
254+
return stripOCIPullProgress(out), err
254255
}

go.mod

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ require (
1515
github.com/spf13/cobra v1.10.2
1616
github.com/spf13/pflag v1.0.10
1717
github.com/stretchr/testify v1.11.1
18-
golang.org/x/term v0.44.0
18+
golang.org/x/term v0.45.0
1919
gopkg.in/yaml.v2 v2.4.0
20-
helm.sh/helm/v4 v4.2.1
21-
k8s.io/api v0.36.2
22-
k8s.io/apiextensions-apiserver v0.36.1
23-
k8s.io/apimachinery v0.36.2
24-
k8s.io/cli-runtime v0.36.2
25-
k8s.io/client-go v0.36.2
20+
helm.sh/helm/v4 v4.2.3
21+
k8s.io/api v0.36.3
22+
k8s.io/apiextensions-apiserver v0.36.3
23+
k8s.io/apimachinery v0.36.3
24+
k8s.io/cli-runtime v0.36.3
25+
k8s.io/client-go v0.36.3
2626
sigs.k8s.io/yaml v1.6.0
2727
)
2828

@@ -118,19 +118,19 @@ require (
118118
go.opentelemetry.io/proto/otlp v1.10.0 // indirect
119119
go.yaml.in/yaml/v2 v2.4.4 // indirect
120120
go.yaml.in/yaml/v3 v3.0.4 // indirect
121-
golang.org/x/crypto v0.53.0 // indirect
122-
golang.org/x/net v0.55.0 // indirect
121+
golang.org/x/crypto v0.54.0 // indirect
122+
golang.org/x/net v0.56.0 // indirect
123123
golang.org/x/oauth2 v0.36.0 // indirect
124-
golang.org/x/sync v0.21.0 // indirect
125-
golang.org/x/sys v0.46.0 // indirect
126-
golang.org/x/text v0.38.0 // indirect
124+
golang.org/x/sync v0.22.0 // indirect
125+
golang.org/x/sys v0.47.0 // indirect
126+
golang.org/x/text v0.40.0 // indirect
127127
golang.org/x/time v0.15.0 // indirect
128128
google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af // indirect
129129
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
130130
gopkg.in/inf.v0 v0.9.1 // indirect
131131
gopkg.in/yaml.v3 v3.0.1 // indirect
132-
k8s.io/apiserver v0.36.1 // indirect
133-
k8s.io/component-base v0.36.1 // indirect
132+
k8s.io/apiserver v0.36.3 // indirect
133+
k8s.io/component-base v0.36.3 // indirect
134134
k8s.io/klog/v2 v2.140.0 // indirect
135135
k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a // indirect
136136
k8s.io/kubectl v0.36.1 // indirect
@@ -141,5 +141,5 @@ require (
141141
sigs.k8s.io/kustomize/api v0.21.1 // indirect
142142
sigs.k8s.io/kustomize/kyaml v0.21.1 // indirect
143143
sigs.k8s.io/randfill v1.0.0 // indirect
144-
sigs.k8s.io/structured-merge-diff/v6 v6.3.2 // indirect
144+
sigs.k8s.io/structured-merge-diff/v6 v6.3.3 // indirect
145145
)

0 commit comments

Comments
 (0)