Skip to content

Commit d64ac13

Browse files
authored
kustomize: Add support for OCI based helm repos (#5167)
* kustomize: Add support for OCI based helm repos Signed-off-by: Jan-Otto Kröpke <[email protected]> * Update api/internal/builtins/HelmChartInflationGenerator.go * Update plugin/builtin/helmchartinflationgenerator/HelmChartInflationGenerator.go * go fmt Signed-off-by: Jan-Otto Kröpke <[email protected]> * s/expectedHelmExternalDns/expectedHelmExternalDNS Signed-off-by: Jan-Otto Kröpke <[email protected]> * commit Signed-off-by: Jan-Otto Kröpke <[email protected]> * commit with content Signed-off-by: Jan-Otto Kröpke <[email protected]> * Apply suggestions from maintainer * go work sync * added test --------- Signed-off-by: Jan-Otto Kröpke <[email protected]>
1 parent f80d9c4 commit d64ac13

File tree

80 files changed

+452
-119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+452
-119
lines changed

api/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ require (
3131
github.com/sergi/go-diff v1.1.0 // indirect
3232
github.com/xlab/treeprint v1.2.0 // indirect
3333
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
34-
golang.org/x/sys v0.8.0 // indirect
34+
golang.org/x/sys v0.12.0 // indirect
3535
google.golang.org/protobuf v1.30.0 // indirect
3636
gopkg.in/yaml.v3 v3.0.1 // indirect
3737
)

api/go.sum

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd
6262
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 h1:+FNtrFTmVw0YZGpBGX56XDee331t6JAXeK2bcyhLOOc=
6363
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o=
6464
golang.org/x/sys v0.0.0-20191002063906-3421d5a6bb1c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
65-
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
66-
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
65+
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
6766
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
6867
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
6968
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=

api/internal/builtins/HelmChartInflationGenerator.go

Lines changed: 12 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/krusty/helmchartinflationgenerator_test.go

Lines changed: 152 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import (
1212
"sigs.k8s.io/kustomize/kyaml/copyutil"
1313
)
1414

15-
const expectedHelm = `
15+
const (
16+
expectedHelm = `
1617
apiVersion: v1
1718
data:
1819
rcon-password: Q0hBTkdFTUUh
@@ -46,6 +47,98 @@ spec:
4647
type: ClusterIP
4748
`
4849

50+
expectedHelmExternalDNS = `
51+
apiVersion: apps/v1
52+
kind: Deployment
53+
metadata:
54+
labels:
55+
app.kubernetes.io/instance: test
56+
app.kubernetes.io/managed-by: Helm
57+
app.kubernetes.io/name: external-dns
58+
helm.sh/chart: external-dns-6.19.2
59+
name: test-external-dns
60+
namespace: default
61+
spec:
62+
replicas: 1
63+
selector:
64+
matchLabels:
65+
app.kubernetes.io/instance: test
66+
app.kubernetes.io/name: external-dns
67+
template:
68+
metadata:
69+
annotations: null
70+
labels:
71+
app.kubernetes.io/instance: test
72+
app.kubernetes.io/managed-by: Helm
73+
app.kubernetes.io/name: external-dns
74+
helm.sh/chart: external-dns-6.19.2
75+
spec:
76+
affinity:
77+
nodeAffinity: null
78+
podAffinity: null
79+
podAntiAffinity:
80+
preferredDuringSchedulingIgnoredDuringExecution:
81+
- podAffinityTerm:
82+
labelSelector:
83+
matchLabels:
84+
app.kubernetes.io/instance: test
85+
app.kubernetes.io/name: external-dns
86+
topologyKey: kubernetes.io/hostname
87+
weight: 1
88+
containers:
89+
- args:
90+
- --metrics-address=:7979
91+
- --log-level=info
92+
- --log-format=text
93+
- --policy=upsert-only
94+
- --provider=aws
95+
- --registry=txt
96+
- --interval=1m
97+
- --source=service
98+
- --source=ingress
99+
- --aws-api-retries=3
100+
- --aws-zone-type=
101+
- --aws-batch-change-size=1000
102+
env:
103+
- name: AWS_DEFAULT_REGION
104+
value: us-east-1
105+
envFrom: null
106+
image: docker.io/bitnami/external-dns:0.13.4-debian-11-r14
107+
imagePullPolicy: IfNotPresent
108+
livenessProbe:
109+
failureThreshold: 2
110+
httpGet:
111+
path: /healthz
112+
port: http
113+
initialDelaySeconds: 10
114+
periodSeconds: 10
115+
successThreshold: 1
116+
timeoutSeconds: 5
117+
name: external-dns
118+
ports:
119+
- containerPort: 7979
120+
name: http
121+
readinessProbe:
122+
failureThreshold: 6
123+
httpGet:
124+
path: /healthz
125+
port: http
126+
initialDelaySeconds: 5
127+
periodSeconds: 10
128+
successThreshold: 1
129+
timeoutSeconds: 5
130+
resources:
131+
limits: {}
132+
requests: {}
133+
volumeMounts: null
134+
securityContext:
135+
fsGroup: 1001
136+
runAsUser: 1001
137+
serviceAccountName: default
138+
volumes: null
139+
`
140+
)
141+
49142
func TestHelmChartInflationGeneratorOld(t *testing.T) {
50143
th := kusttest_test.MakeEnhancedHarnessWithTmpRoot(t)
51144
defer th.Reset()
@@ -84,6 +177,64 @@ helmCharts:
84177
th.AssertActualEqualsExpected(m, expectedHelm)
85178
}
86179

180+
func TestHelmChartInflationGeneratorWithOciRepository(t *testing.T) {
181+
th := kusttest_test.MakeEnhancedHarnessWithTmpRoot(t)
182+
defer th.Reset()
183+
if err := th.ErrIfNoHelm(); err != nil {
184+
t.Skip("skipping: " + err.Error())
185+
}
186+
187+
th.WriteK(th.GetRoot(), `
188+
helmCharts:
189+
- name: external-dns
190+
repo: oci://registry-1.docker.io/bitnamicharts
191+
version: 6.19.2
192+
releaseName: test
193+
valuesInline:
194+
crd:
195+
create: false
196+
rbac:
197+
create: false
198+
serviceAccount:
199+
create: false
200+
service:
201+
enabled: false
202+
203+
`)
204+
205+
m := th.Run(th.GetRoot(), th.MakeOptionsPluginsEnabled())
206+
th.AssertActualEqualsExpected(m, expectedHelmExternalDNS)
207+
}
208+
209+
func TestHelmChartInflationGeneratorWithOciRepositoryWithAppendSlash(t *testing.T) {
210+
th := kusttest_test.MakeEnhancedHarnessWithTmpRoot(t)
211+
defer th.Reset()
212+
if err := th.ErrIfNoHelm(); err != nil {
213+
t.Skip("skipping: " + err.Error())
214+
}
215+
216+
th.WriteK(th.GetRoot(), `
217+
helmCharts:
218+
- name: external-dns
219+
repo: oci://registry-1.docker.io/bitnamicharts/
220+
version: 6.19.2
221+
releaseName: test
222+
valuesInline:
223+
crd:
224+
create: false
225+
rbac:
226+
create: false
227+
serviceAccount:
228+
create: false
229+
service:
230+
enabled: false
231+
232+
`)
233+
234+
m := th.Run(th.GetRoot(), th.MakeOptionsPluginsEnabled())
235+
th.AssertActualEqualsExpected(m, expectedHelmExternalDNS)
236+
}
237+
87238
// Last mile helm - show how kustomize puts helm charts into different
88239
// namespaces with different customizations.
89240
func TestHelmChartProdVsDev(t *testing.T) {

cmd/config/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ require (
2828
github.com/spf13/pflag v1.0.5 // indirect
2929
github.com/xlab/treeprint v1.2.0 // indirect
3030
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
31-
golang.org/x/sys v0.8.0 // indirect
31+
golang.org/x/sys v0.12.0 // indirect
3232
google.golang.org/protobuf v1.30.0 // indirect
3333
gopkg.in/yaml.v2 v2.4.0 // indirect
3434
gopkg.in/yaml.v3 v3.0.1 // indirect

cmd/config/go.sum

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd
6464
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 h1:+FNtrFTmVw0YZGpBGX56XDee331t6JAXeK2bcyhLOOc=
6565
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5/go.mod h1:nmDLcffg48OtT/PSW0Hg7FvpRQsQh5OSqIylirxKC7o=
6666
golang.org/x/sys v0.0.0-20191002063906-3421d5a6bb1c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
67-
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
68-
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
67+
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
6968
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
7069
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
7170
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=

cmd/config/internal/commands/e2e/e2econtainerconfig/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ require (
2222
github.com/spf13/cobra v1.7.0 // indirect
2323
github.com/spf13/pflag v1.0.5 // indirect
2424
github.com/xlab/treeprint v1.2.0 // indirect
25-
golang.org/x/sys v0.8.0 // indirect
25+
golang.org/x/sys v0.12.0 // indirect
2626
google.golang.org/protobuf v1.30.0 // indirect
2727
gopkg.in/yaml.v2 v2.4.0 // indirect
2828
gopkg.in/yaml.v3 v3.0.1 // indirect

cmd/config/internal/commands/e2e/e2econtainerconfig/go.sum

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs
5858
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
5959
github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=
6060
github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
61-
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
62-
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
61+
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
6362
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
6463
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
6564
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=

cmd/depprobcheck/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ require (
4545
github.com/spf13/pflag v1.0.5 // indirect
4646
golang.org/x/net v0.8.0 // indirect
4747
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
48-
golang.org/x/sys v0.8.0 // indirect
48+
golang.org/x/sys v0.12.0 // indirect
4949
golang.org/x/term v0.6.0 // indirect
5050
golang.org/x/text v0.8.0 // indirect
5151
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect

cmd/depprobcheck/go.sum

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,7 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w
532532
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
533533
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
534534
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
535-
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
536-
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
535+
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
537536
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
538537
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
539538
golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=

0 commit comments

Comments
 (0)