@@ -34,103 +34,8 @@ import (
34
34
"sigs.k8s.io/kubebuilder/v3/test/e2e/utils"
35
35
)
36
36
37
- // GenerateV2 implements a go/v2 plugin project defined by a TestContext.
38
- func GenerateV2 (kbc * utils.TestContext ) {
39
- var err error
40
-
41
- By ("initializing a project" )
42
- err = kbc .Init (
43
- "--plugins" , "go/v2" ,
44
- "--project-version" , "3" ,
45
- "--domain" , kbc .Domain ,
46
- "--fetch-deps=false" ,
47
- )
48
- ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
49
-
50
- By ("creating API definition" )
51
- err = kbc .CreateAPI (
52
- "--group" , kbc .Group ,
53
- "--version" , kbc .Version ,
54
- "--kind" , kbc .Kind ,
55
- "--namespaced" ,
56
- "--resource" ,
57
- "--controller" ,
58
- "--make=false" ,
59
- )
60
- ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
61
-
62
- By ("implementing the API" )
63
- ExpectWithOffset (1 , pluginutil .InsertCode (
64
- filepath .Join (kbc .Dir , "api" , kbc .Version , fmt .Sprintf ("%s_types.go" , strings .ToLower (kbc .Kind ))),
65
- fmt .Sprintf (`type %sSpec struct {
66
- ` , kbc .Kind ),
67
- ` // +optional
68
- Count int ` + "`" + `json:"count,omitempty"` + "`" + `
69
- ` )).Should (Succeed ())
70
-
71
- By ("scaffolding mutating and validating webhooks" )
72
- err = kbc .CreateWebhook (
73
- "--group" , kbc .Group ,
74
- "--version" , kbc .Version ,
75
- "--kind" , kbc .Kind ,
76
- "--defaulting" ,
77
- "--programmatic-validation" ,
78
- )
79
- ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
80
-
81
- By ("implementing the mutating and validating webhooks" )
82
- err = pluginutil .ImplementWebhooks (filepath .Join (
83
- kbc .Dir , "api" , kbc .Version ,
84
- fmt .Sprintf ("%s_webhook.go" , strings .ToLower (kbc .Kind ))))
85
- ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
86
-
87
- By ("uncomment kustomization.yaml to enable webhook and ca injection" )
88
- ExpectWithOffset (1 , pluginutil .UncommentCode (
89
- filepath .Join (kbc .Dir , "config" , "default" , "kustomization.yaml" ),
90
- "#- ../webhook" , "#" )).To (Succeed ())
91
- ExpectWithOffset (1 , pluginutil .UncommentCode (
92
- filepath .Join (kbc .Dir , "config" , "default" , "kustomization.yaml" ),
93
- "#- ../certmanager" , "#" )).To (Succeed ())
94
- ExpectWithOffset (1 , pluginutil .UncommentCode (
95
- filepath .Join (kbc .Dir , "config" , "default" , "kustomization.yaml" ),
96
- "#- ../prometheus" , "#" )).To (Succeed ())
97
- ExpectWithOffset (1 , pluginutil .UncommentCode (
98
- filepath .Join (kbc .Dir , "config" , "default" , "kustomization.yaml" ),
99
- "#- manager_webhook_patch.yaml" , "#" )).To (Succeed ())
100
- ExpectWithOffset (1 , pluginutil .UncommentCode (
101
- filepath .Join (kbc .Dir , "config" , "default" , "kustomization.yaml" ),
102
- "#- webhookcainjection_patch.yaml" , "#" )).To (Succeed ())
103
- ExpectWithOffset (1 , pluginutil .UncommentCode (filepath .Join (kbc .Dir , "config" , "default" , "kustomization.yaml" ),
104
- `#- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR
105
- # objref:
106
- # kind: Certificate
107
- # group: cert-manager.io
108
- # version: v1alpha2
109
- # name: serving-cert # this name should match the one in certificate.yaml
110
- # fieldref:
111
- # fieldpath: metadata.namespace
112
- #- name: CERTIFICATE_NAME
113
- # objref:
114
- # kind: Certificate
115
- # group: cert-manager.io
116
- # version: v1alpha2
117
- # name: serving-cert # this name should match the one in certificate.yaml
118
- #- name: SERVICE_NAMESPACE # namespace of the service
119
- # objref:
120
- # kind: Service
121
- # version: v1
122
- # name: webhook-service
123
- # fieldref:
124
- # fieldpath: metadata.namespace
125
- #- name: SERVICE_NAME
126
- # objref:
127
- # kind: Service
128
- # version: v1
129
- # name: webhook-service` , "#" )).To (Succeed ())
130
- }
131
-
132
37
// GenerateV3 implements a go/v3(-alpha) plugin project defined by a TestContext.
133
- func GenerateV3 (kbc * utils.TestContext , crdAndWebhookVersion string ) {
38
+ func GenerateV3 (kbc * utils.TestContext ) {
134
39
var err error
135
40
136
41
By ("initializing a project" )
@@ -151,7 +56,6 @@ func GenerateV3(kbc *utils.TestContext, crdAndWebhookVersion string) {
151
56
"--resource" ,
152
57
"--controller" ,
153
58
"--make=false" ,
154
- "--crd-version" , crdAndWebhookVersion ,
155
59
)
156
60
ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
157
61
@@ -171,7 +75,6 @@ Count int `+"`"+`json:"count,omitempty"`+"`"+`
171
75
"--kind" , kbc .Kind ,
172
76
"--defaulting" ,
173
77
"--programmatic-validation" ,
174
- "--webhook-version" , crdAndWebhookVersion ,
175
78
)
176
79
ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
177
80
@@ -225,18 +128,14 @@ Count int `+"`"+`json:"count,omitempty"`+"`"+`
225
128
# version: v1
226
129
# name: webhook-service` , "#" )).To (Succeed ())
227
130
228
- if crdAndWebhookVersion == "v1beta1" {
229
- _ = pluginutil .RunCmd ("Update dependencies" , "go" , "mod" , "tidy" )
230
- }
231
-
232
131
if kbc .IsRestricted {
233
132
By ("uncomment kustomize files to ensure that pods are restricted" )
234
133
uncommentPodStandards (kbc )
235
134
}
236
135
}
237
136
238
- // GenerateV3 implements a go/v3(-alpha) plugin project defined by a TestContext.
239
- func GenerateV3ComponentConfig (kbc * utils.TestContext , crdAndWebhookVersion string ) {
137
+ // GenerateV3ComponentConfig implements a go/v3(-alpha) plugin project defined by a TestContext with component config .
138
+ func GenerateV3ComponentConfig (kbc * utils.TestContext ) {
240
139
var err error
241
140
242
141
By ("initializing a project" )
@@ -258,7 +157,6 @@ func GenerateV3ComponentConfig(kbc *utils.TestContext, crdAndWebhookVersion stri
258
157
"--resource" ,
259
158
"--controller" ,
260
159
"--make=false" ,
261
- "--crd-version" , crdAndWebhookVersion ,
262
160
)
263
161
ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
264
162
@@ -278,7 +176,6 @@ Count int `+"`"+`json:"count,omitempty"`+"`"+`
278
176
"--kind" , kbc .Kind ,
279
177
"--defaulting" ,
280
178
"--programmatic-validation" ,
281
- "--webhook-version" , crdAndWebhookVersion ,
282
179
)
283
180
ExpectWithOffset (1 , err ).NotTo (HaveOccurred ())
284
181
@@ -332,10 +229,6 @@ Count int `+"`"+`json:"count,omitempty"`+"`"+`
332
229
# version: v1
333
230
# name: webhook-service` , "#" )).To (Succeed ())
334
231
335
- if crdAndWebhookVersion == "v1beta1" {
336
- _ = pluginutil .RunCmd ("Update dependencies" , "go" , "mod" , "tidy" )
337
- }
338
-
339
232
if kbc .IsRestricted {
340
233
By ("uncomment kustomize files to ensure that pods are restricted" )
341
234
uncommentPodStandards (kbc )
0 commit comments