Skip to content

Commit 47e6cab

Browse files
authored
Merge pull request #3456 from mjlshen/3374
🐛 Fix kustomize syntax during conversion to patches
2 parents 3a3d1d9 + 9444a67 commit 47e6cab

File tree

10 files changed

+49
-44
lines changed

10 files changed

+49
-44
lines changed

docs/book/src/component-config-tutorial/testdata/project/config/crd/kustomization.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ resources:
88
patches:
99
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
1010
# patches here are for enabling the conversion webhook for each CRD
11-
#- patches/webhook_in_projectconfigs.yaml
11+
#- path: patches/webhook_in_projectconfigs.yaml
1212
#+kubebuilder:scaffold:crdkustomizewebhookpatch
1313

1414
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
1515
# patches here are for enabling the CA injection for each CRD
16-
#- patches/cainjection_in_projectconfigs.yaml
16+
#- path: patches/cainjection_in_projectconfigs.yaml
1717
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
1818

1919
# the following config is for teaching kustomize how to do kustomization for CRDs.

docs/book/src/cronjob-tutorial/testdata/project/config/crd/kustomization.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ resources:
88
patches:
99
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
1010
# patches here are for enabling the conversion webhook for each CRD
11-
- patches/webhook_in_cronjobs.yaml
11+
- path: patches/webhook_in_cronjobs.yaml
1212
#+kubebuilder:scaffold:crdkustomizewebhookpatch
1313

1414
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
1515
# patches here are for enabling the CA injection for each CRD
16-
- patches/cainjection_in_cronjobs.yaml
16+
- path: patches/cainjection_in_cronjobs.yaml
1717
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
1818

1919
# the following config is for teaching kustomize how to do kustomization for CRDs.

hack/docs/internal/cronjob-tutorial/generate_cronjob.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,12 +581,12 @@ func updateKustomization(sp *Sample) {
581581
// uncomment crd/kustomization
582582
err = pluginutil.UncommentCode(
583583
filepath.Join(sp.ctx.Dir, "config/crd/kustomization.yaml"),
584-
`#- patches/webhook_in_cronjobs.yaml`, `#`)
584+
`#- path: patches/webhook_in_cronjobs.yaml`, `#`)
585585
CheckError("fixing crd/kustomization", err)
586586

587587
err = pluginutil.UncommentCode(
588588
filepath.Join(sp.ctx.Dir, "config/crd/kustomization.yaml"),
589-
`#- patches/cainjection_in_cronjobs.yaml`, `#`)
589+
`#- path: patches/cainjection_in_cronjobs.yaml`, `#`)
590590
CheckError("fixing crd/kustomization", err)
591591
}
592592

pkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/crd/kustomization.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ func (f *Kustomization) GetMarkers() []machinery.Marker {
6868
const (
6969
resourceCodeFragment = `- bases/%s_%s.yaml
7070
`
71-
webhookPatchCodeFragment = `#- patches/webhook_in_%s.yaml
71+
webhookPatchCodeFragment = `#- path: patches/webhook_in_%s.yaml
7272
`
73-
caInjectionPatchCodeFragment = `#- patches/cainjection_in_%s.yaml
73+
caInjectionPatchCodeFragment = `#- path: patches/cainjection_in_%s.yaml
7474
`
7575
)
7676

pkg/plugins/golang/declarative/v1/api.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@ import (
2020
"errors"
2121
"fmt"
2222

23-
goPluginV3 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3"
24-
2523
"sigs.k8s.io/kubebuilder/v3/pkg/config"
2624
"sigs.k8s.io/kubebuilder/v3/pkg/machinery"
2725
"sigs.k8s.io/kubebuilder/v3/pkg/model/resource"
2826
"sigs.k8s.io/kubebuilder/v3/pkg/plugin"
2927
"sigs.k8s.io/kubebuilder/v3/pkg/plugin/util"
3028
"sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/declarative/v1/scaffolds"
3129
goPluginV2 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v2"
30+
goPluginV3 "sigs.k8s.io/kubebuilder/v3/pkg/plugins/golang/v3"
3231
)
3332

3433
const (

test/e2e/v4/generate_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ Count int `+"`"+`json:"count,omitempty"`+"`"+`
8383
ExpectWithOffset(1, err).NotTo(HaveOccurred())
8484

8585
By("uncomment kustomization.yaml to enable webhook and ca injection")
86+
ExpectWithOffset(1, pluginutil.UncommentCode(
87+
filepath.Join(kbc.Dir, "config", "crd", "kustomization.yaml"),
88+
fmt.Sprintf("#- path: patches/webhook_in_%s.yaml", kbc.Resources), "#")).To(Succeed())
89+
ExpectWithOffset(1, pluginutil.UncommentCode(
90+
filepath.Join(kbc.Dir, "config", "crd", "kustomization.yaml"),
91+
fmt.Sprintf("#- path: patches/cainjection_in_%s.yaml", kbc.Resources), "#")).To(Succeed())
8692
ExpectWithOffset(1, pluginutil.UncommentCode(
8793
filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
8894
"#- ../webhook", "#")).To(Succeed())

testdata/project-v4-declarative-v1/config/crd/kustomization.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ resources:
1010
patches:
1111
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
1212
# patches here are for enabling the conversion webhook for each CRD
13-
#- patches/webhook_in_captains.yaml
14-
#- patches/webhook_in_firstmates.yaml
15-
#- patches/webhook_in_admirals.yaml
13+
#- path: patches/webhook_in_captains.yaml
14+
#- path: patches/webhook_in_firstmates.yaml
15+
#- path: patches/webhook_in_admirals.yaml
1616
#+kubebuilder:scaffold:crdkustomizewebhookpatch
1717

1818
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
1919
# patches here are for enabling the CA injection for each CRD
20-
#- patches/cainjection_in_captains.yaml
21-
#- patches/cainjection_in_firstmates.yaml
22-
#- patches/cainjection_in_admirals.yaml
20+
#- path: patches/cainjection_in_captains.yaml
21+
#- path: patches/cainjection_in_firstmates.yaml
22+
#- path: patches/cainjection_in_admirals.yaml
2323
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
2424

2525
# the following config is for teaching kustomize how to do kustomization for CRDs.

testdata/project-v4-multigroup/config/crd/kustomization.yaml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,28 @@ resources:
1717
patches:
1818
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
1919
# patches here are for enabling the conversion webhook for each CRD
20-
#- patches/webhook_in_captains.yaml
21-
#- patches/webhook_in_frigates.yaml
22-
#- patches/webhook_in_destroyers.yaml
23-
#- patches/webhook_in_cruisers.yaml
24-
#- patches/webhook_in_krakens.yaml
25-
#- patches/webhook_in_leviathans.yaml
26-
#- patches/webhook_in_healthcheckpolicies.yaml
27-
#- patches/webhook_in_bars.yaml
28-
#- patches/webhook_in_lakers.yaml
20+
#- path: patches/webhook_in_captains.yaml
21+
#- path: patches/webhook_in_frigates.yaml
22+
#- path: patches/webhook_in_destroyers.yaml
23+
#- path: patches/webhook_in_cruisers.yaml
24+
#- path: patches/webhook_in_krakens.yaml
25+
#- path: patches/webhook_in_leviathans.yaml
26+
#- path: patches/webhook_in_healthcheckpolicies.yaml
27+
#- path: patches/webhook_in_bars.yaml
28+
#- path: patches/webhook_in_lakers.yaml
2929
#+kubebuilder:scaffold:crdkustomizewebhookpatch
3030

3131
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
3232
# patches here are for enabling the CA injection for each CRD
33-
#- patches/cainjection_in_captains.yaml
34-
#- patches/cainjection_in_frigates.yaml
35-
#- patches/cainjection_in_destroyers.yaml
36-
#- patches/cainjection_in_cruisers.yaml
37-
#- patches/cainjection_in_krakens.yaml
38-
#- patches/cainjection_in_leviathans.yaml
39-
#- patches/cainjection_in_healthcheckpolicies.yaml
40-
#- patches/cainjection_in_bars.yaml
41-
#- patches/cainjection_in_lakers.yaml
33+
#- path: patches/cainjection_in_captains.yaml
34+
#- path: patches/cainjection_in_frigates.yaml
35+
#- path: patches/cainjection_in_destroyers.yaml
36+
#- path: patches/cainjection_in_cruisers.yaml
37+
#- path: patches/cainjection_in_krakens.yaml
38+
#- path: patches/cainjection_in_leviathans.yaml
39+
#- path: patches/cainjection_in_healthcheckpolicies.yaml
40+
#- path: patches/cainjection_in_bars.yaml
41+
#- path: patches/cainjection_in_lakers.yaml
4242
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
4343

4444
# the following config is for teaching kustomize how to do kustomization for CRDs.

testdata/project-v4-with-deploy-image/config/crd/kustomization.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ resources:
99
patches:
1010
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
1111
# patches here are for enabling the conversion webhook for each CRD
12-
#- patches/webhook_in_memcacheds.yaml
13-
#- patches/webhook_in_busyboxes.yaml
12+
#- path: patches/webhook_in_memcacheds.yaml
13+
#- path: patches/webhook_in_busyboxes.yaml
1414
#+kubebuilder:scaffold:crdkustomizewebhookpatch
1515

1616
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
1717
# patches here are for enabling the CA injection for each CRD
18-
#- patches/cainjection_in_memcacheds.yaml
19-
#- patches/cainjection_in_busyboxes.yaml
18+
#- path: patches/cainjection_in_memcacheds.yaml
19+
#- path: patches/cainjection_in_busyboxes.yaml
2020
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
2121

2222
# the following config is for teaching kustomize how to do kustomization for CRDs.

testdata/project-v4/config/crd/kustomization.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ resources:
1010
patches:
1111
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
1212
# patches here are for enabling the conversion webhook for each CRD
13-
#- patches/webhook_in_captains.yaml
14-
#- patches/webhook_in_firstmates.yaml
15-
#- patches/webhook_in_admirales.yaml
13+
#- path: patches/webhook_in_captains.yaml
14+
#- path: patches/webhook_in_firstmates.yaml
15+
#- path: patches/webhook_in_admirales.yaml
1616
#+kubebuilder:scaffold:crdkustomizewebhookpatch
1717

1818
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
1919
# patches here are for enabling the CA injection for each CRD
20-
#- patches/cainjection_in_captains.yaml
21-
#- patches/cainjection_in_firstmates.yaml
22-
#- patches/cainjection_in_admirales.yaml
20+
#- path: patches/cainjection_in_captains.yaml
21+
#- path: patches/cainjection_in_firstmates.yaml
22+
#- path: patches/cainjection_in_admirales.yaml
2323
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
2424

2525
# the following config is for teaching kustomize how to do kustomization for CRDs.

0 commit comments

Comments
 (0)