@@ -62,6 +62,8 @@ var _ = Describe("Options", func() {
62
62
for _ , multiGroup := range []bool {false , true } {
63
63
if multiGroup {
64
64
Expect (cfg .SetMultiGroup ()).To (Succeed ())
65
+ } else {
66
+ Expect (cfg .ClearMultiGroup ()).To (Succeed ())
65
67
}
66
68
67
69
resource := options .NewResource (cfg )
@@ -70,19 +72,36 @@ var _ = Describe("Options", func() {
70
72
Expect (resource .Domain ).To (Equal (options .Domain ))
71
73
Expect (resource .Version ).To (Equal (options .Version ))
72
74
Expect (resource .Kind ).To (Equal (options .Kind ))
73
- if multiGroup {
74
- Expect (resource .Path ).To (Equal (
75
- path .Join (cfg .GetRepository (), "apis" , options .Group , options .Version )))
75
+ Expect (resource .API ).NotTo (BeNil ())
76
+ if options .DoAPI || options .DoDefaulting || options .DoValidation || options .DoConversion {
77
+ if multiGroup {
78
+ Expect (resource .Path ).To (Equal (
79
+ path .Join (cfg .GetRepository (), "apis" , options .Group , options .Version )))
80
+ } else {
81
+ Expect (resource .Path ).To (Equal (path .Join (cfg .GetRepository (), "api" , options .Version )))
82
+ }
76
83
} else {
77
- Expect (resource .Path ).To (Equal (path .Join (cfg .GetRepository (), "api" , options .Version )))
84
+ // Core-resources have a path despite not having an API/Webhook but they are not tested here
85
+ Expect (resource .Path ).To (Equal ("" ))
86
+ }
87
+ if options .DoAPI {
88
+ Expect (resource .API .CRDVersion ).To (Equal (options .CRDVersion ))
89
+ Expect (resource .API .Namespaced ).To (Equal (options .Namespaced ))
90
+ Expect (resource .API .IsEmpty ()).To (BeFalse ())
91
+ } else {
92
+ Expect (resource .API .IsEmpty ()).To (BeTrue ())
78
93
}
79
- Expect (resource .API .CRDVersion ).To (Equal (options .CRDVersion ))
80
- Expect (resource .API .Namespaced ).To (Equal (options .Namespaced ))
81
94
Expect (resource .Controller ).To (Equal (options .DoController ))
82
- Expect (resource .Webhooks .WebhookVersion ).To (Equal (options .WebhookVersion ))
83
- Expect (resource .Webhooks .Defaulting ).To (Equal (options .DoDefaulting ))
84
- Expect (resource .Webhooks .Validation ).To (Equal (options .DoValidation ))
85
- Expect (resource .Webhooks .Conversion ).To (Equal (options .DoConversion ))
95
+ Expect (resource .Webhooks ).NotTo (BeNil ())
96
+ if options .DoDefaulting || options .DoValidation || options .DoConversion {
97
+ Expect (resource .Webhooks .WebhookVersion ).To (Equal (options .WebhookVersion ))
98
+ Expect (resource .Webhooks .Defaulting ).To (Equal (options .DoDefaulting ))
99
+ Expect (resource .Webhooks .Validation ).To (Equal (options .DoValidation ))
100
+ Expect (resource .Webhooks .Conversion ).To (Equal (options .DoConversion ))
101
+ Expect (resource .Webhooks .IsEmpty ()).To (BeFalse ())
102
+ } else {
103
+ Expect (resource .Webhooks .IsEmpty ()).To (BeTrue ())
104
+ }
86
105
Expect (resource .QualifiedGroup ()).To (Equal (options .Group + "." + options .Domain ))
87
106
Expect (resource .PackageName ()).To (Equal (options .Group ))
88
107
Expect (resource .ImportAlias ()).To (Equal (options .Group + options .Version ))
@@ -130,6 +149,8 @@ var _ = Describe("Options", func() {
130
149
for _ , multiGroup := range []bool {false , true } {
131
150
if multiGroup {
132
151
Expect (cfg .SetMultiGroup ()).To (Succeed ())
152
+ } else {
153
+ Expect (cfg .ClearMultiGroup ()).To (Succeed ())
133
154
}
134
155
135
156
resource := options .NewResource (cfg )
@@ -150,6 +171,8 @@ var _ = Describe("Options", func() {
150
171
for _ , multiGroup := range []bool {false , true } {
151
172
if multiGroup {
152
173
Expect (cfg .SetMultiGroup ()).To (Succeed ())
174
+ } else {
175
+ Expect (cfg .ClearMultiGroup ()).To (Succeed ())
153
176
}
154
177
155
178
resource := options .NewResource (cfg )
@@ -168,12 +191,15 @@ var _ = Describe("Options", func() {
168
191
Domain : "test.io" ,
169
192
Version : "v1" ,
170
193
Kind : "FirstMate" ,
194
+ DoAPI : true , // Scaffold the API so that the path is saved
171
195
}
172
196
Expect (options .Validate ()).To (Succeed ())
173
197
174
198
for _ , multiGroup := range []bool {false , true } {
175
199
if multiGroup {
176
200
Expect (cfg .SetMultiGroup ()).To (Succeed ())
201
+ } else {
202
+ Expect (cfg .ClearMultiGroup ()).To (Succeed ())
177
203
}
178
204
179
205
resource := options .NewResource (cfg )
@@ -201,6 +227,8 @@ var _ = Describe("Options", func() {
201
227
for _ , multiGroup := range []bool {false , true } {
202
228
if multiGroup {
203
229
Expect (cfg .SetMultiGroup ()).To (Succeed ())
230
+ } else {
231
+ Expect (cfg .ClearMultiGroup ()).To (Succeed ())
204
232
}
205
233
206
234
resource := options .NewResource (cfg )
@@ -222,12 +250,15 @@ var _ = Describe("Options", func() {
222
250
for _ , multiGroup := range []bool {false , true } {
223
251
if multiGroup {
224
252
Expect (cfg .SetMultiGroup ()).To (Succeed ())
253
+ } else {
254
+ Expect (cfg .ClearMultiGroup ()).To (Succeed ())
225
255
}
226
256
227
257
resource := options .NewResource (cfg )
228
258
Expect (resource .Validate ()).To (Succeed ())
229
259
Expect (resource .Path ).To (Equal (path .Join ("k8s.io" , "api" , options .Group , options .Version )))
230
- Expect (resource .API .CRDVersion ).To (Equal ("" ))
260
+ Expect (resource .API ).NotTo (BeNil ())
261
+ Expect (resource .API .IsEmpty ()).To (BeTrue ())
231
262
Expect (resource .QualifiedGroup ()).To (Equal (qualified ))
232
263
}
233
264
},
@@ -242,12 +273,15 @@ var _ = Describe("Options", func() {
242
273
Domain : "test.io" ,
243
274
Version : "v1" ,
244
275
Kind : "FirstMate" ,
276
+ DoAPI : true , // Scaffold the API so that the path is saved
245
277
}
246
278
Expect (options .Validate ()).To (Succeed ())
247
279
248
280
for _ , multiGroup := range []bool {false , true } {
249
281
if multiGroup {
250
282
Expect (cfg .SetMultiGroup ()).To (Succeed ())
283
+ } else {
284
+ Expect (cfg .ClearMultiGroup ()).To (Succeed ())
251
285
}
252
286
253
287
resource := options .NewResource (cfg )
0 commit comments