@@ -19,7 +19,7 @@ package crd_test
19
19
import (
20
20
. "github.com/onsi/ginkgo"
21
21
. "github.com/onsi/gomega"
22
- apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
22
+ apiextlegacy "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
23
23
24
24
"sigs.k8s.io/controller-tools/pkg/crd"
25
25
)
@@ -28,97 +28,97 @@ var _ = Describe("CRD Generation", func() {
28
28
Describe ("Utilities" , func () {
29
29
Describe ("MergeIdenticalVersionInfo" , func () {
30
30
It ("should replace per-version schemata with a top-level schema if only one version" , func () {
31
- spec := & apiext .CustomResourceDefinition {
32
- Spec : apiext .CustomResourceDefinitionSpec {
33
- Versions : []apiext .CustomResourceDefinitionVersion {
31
+ spec := & apiextlegacy .CustomResourceDefinition {
32
+ Spec : apiextlegacy .CustomResourceDefinitionSpec {
33
+ Versions : []apiextlegacy .CustomResourceDefinitionVersion {
34
34
{
35
35
Name : "v1" ,
36
36
Storage : true ,
37
- Schema : & apiext .CustomResourceValidation {
38
- OpenAPIV3Schema : & apiext .JSONSchemaProps {
37
+ Schema : & apiextlegacy .CustomResourceValidation {
38
+ OpenAPIV3Schema : & apiextlegacy .JSONSchemaProps {
39
39
Required : []string {"foo" },
40
40
Type : "object" ,
41
- Properties : map [string ]apiext .JSONSchemaProps {"foo" : apiext .JSONSchemaProps {Type : "string" }},
41
+ Properties : map [string ]apiextlegacy .JSONSchemaProps {"foo" : apiextlegacy .JSONSchemaProps {Type : "string" }},
42
42
},
43
43
},
44
44
},
45
45
},
46
46
},
47
47
}
48
48
crd .MergeIdenticalVersionInfo (spec )
49
- Expect (spec .Spec .Validation ).To (Equal (& apiext .CustomResourceValidation {
50
- OpenAPIV3Schema : & apiext .JSONSchemaProps {
49
+ Expect (spec .Spec .Validation ).To (Equal (& apiextlegacy .CustomResourceValidation {
50
+ OpenAPIV3Schema : & apiextlegacy .JSONSchemaProps {
51
51
Required : []string {"foo" },
52
52
Type : "object" ,
53
- Properties : map [string ]apiext .JSONSchemaProps {"foo" : apiext .JSONSchemaProps {Type : "string" }},
53
+ Properties : map [string ]apiextlegacy .JSONSchemaProps {"foo" : apiextlegacy .JSONSchemaProps {Type : "string" }},
54
54
},
55
55
}))
56
- Expect (spec .Spec .Versions ).To (Equal ([]apiext .CustomResourceDefinitionVersion {
56
+ Expect (spec .Spec .Versions ).To (Equal ([]apiextlegacy .CustomResourceDefinitionVersion {
57
57
{Name : "v1" , Storage : true },
58
58
}))
59
59
})
60
60
It ("should replace per-version schemata with a top-level schema if all are identical" , func () {
61
- spec := & apiext .CustomResourceDefinition {
62
- Spec : apiext .CustomResourceDefinitionSpec {
63
- Versions : []apiext .CustomResourceDefinitionVersion {
61
+ spec := & apiextlegacy .CustomResourceDefinition {
62
+ Spec : apiextlegacy .CustomResourceDefinitionSpec {
63
+ Versions : []apiextlegacy .CustomResourceDefinitionVersion {
64
64
{
65
65
Name : "v1" ,
66
- Schema : & apiext .CustomResourceValidation {
67
- OpenAPIV3Schema : & apiext .JSONSchemaProps {
66
+ Schema : & apiextlegacy .CustomResourceValidation {
67
+ OpenAPIV3Schema : & apiextlegacy .JSONSchemaProps {
68
68
Required : []string {"foo" },
69
69
Type : "object" ,
70
- Properties : map [string ]apiext .JSONSchemaProps {"foo" : apiext .JSONSchemaProps {Type : "string" }},
70
+ Properties : map [string ]apiextlegacy .JSONSchemaProps {"foo" : apiextlegacy .JSONSchemaProps {Type : "string" }},
71
71
},
72
72
},
73
73
},
74
74
{
75
75
Name : "v2" ,
76
76
Storage : true ,
77
- Schema : & apiext .CustomResourceValidation {
78
- OpenAPIV3Schema : & apiext .JSONSchemaProps {
77
+ Schema : & apiextlegacy .CustomResourceValidation {
78
+ OpenAPIV3Schema : & apiextlegacy .JSONSchemaProps {
79
79
Required : []string {"foo" },
80
80
Type : "object" ,
81
- Properties : map [string ]apiext .JSONSchemaProps {"foo" : apiext .JSONSchemaProps {Type : "string" }},
81
+ Properties : map [string ]apiextlegacy .JSONSchemaProps {"foo" : apiextlegacy .JSONSchemaProps {Type : "string" }},
82
82
},
83
83
},
84
84
},
85
85
},
86
86
},
87
87
}
88
88
crd .MergeIdenticalVersionInfo (spec )
89
- Expect (spec .Spec .Validation ).To (Equal (& apiext .CustomResourceValidation {
90
- OpenAPIV3Schema : & apiext .JSONSchemaProps {
89
+ Expect (spec .Spec .Validation ).To (Equal (& apiextlegacy .CustomResourceValidation {
90
+ OpenAPIV3Schema : & apiextlegacy .JSONSchemaProps {
91
91
Required : []string {"foo" },
92
92
Type : "object" ,
93
- Properties : map [string ]apiext .JSONSchemaProps {"foo" : apiext .JSONSchemaProps {Type : "string" }},
93
+ Properties : map [string ]apiextlegacy .JSONSchemaProps {"foo" : apiextlegacy .JSONSchemaProps {Type : "string" }},
94
94
},
95
95
}))
96
- Expect (spec .Spec .Versions ).To (Equal ([]apiext .CustomResourceDefinitionVersion {
96
+ Expect (spec .Spec .Versions ).To (Equal ([]apiextlegacy .CustomResourceDefinitionVersion {
97
97
{Name : "v1" }, {Name : "v2" , Storage : true },
98
98
}))
99
99
})
100
100
101
101
It ("shouldn't merge different schemata" , func () {
102
- spec := & apiext .CustomResourceDefinition {
103
- Spec : apiext .CustomResourceDefinitionSpec {
104
- Versions : []apiext .CustomResourceDefinitionVersion {
102
+ spec := & apiextlegacy .CustomResourceDefinition {
103
+ Spec : apiextlegacy .CustomResourceDefinitionSpec {
104
+ Versions : []apiextlegacy .CustomResourceDefinitionVersion {
105
105
{
106
106
Name : "v1" ,
107
- Schema : & apiext .CustomResourceValidation {
108
- OpenAPIV3Schema : & apiext .JSONSchemaProps {
107
+ Schema : & apiextlegacy .CustomResourceValidation {
108
+ OpenAPIV3Schema : & apiextlegacy .JSONSchemaProps {
109
109
Type : "object" ,
110
- Properties : map [string ]apiext .JSONSchemaProps {"foo" : apiext .JSONSchemaProps {Type : "string" }},
110
+ Properties : map [string ]apiextlegacy .JSONSchemaProps {"foo" : apiextlegacy .JSONSchemaProps {Type : "string" }},
111
111
},
112
112
},
113
113
},
114
114
{
115
115
Name : "v2" ,
116
116
Storage : true ,
117
- Schema : & apiext .CustomResourceValidation {
118
- OpenAPIV3Schema : & apiext .JSONSchemaProps {
117
+ Schema : & apiextlegacy .CustomResourceValidation {
118
+ OpenAPIV3Schema : & apiextlegacy .JSONSchemaProps {
119
119
Required : []string {"foo" },
120
120
Type : "object" ,
121
- Properties : map [string ]apiext .JSONSchemaProps {"foo" : apiext .JSONSchemaProps {Type : "string" }},
121
+ Properties : map [string ]apiextlegacy .JSONSchemaProps {"foo" : apiextlegacy .JSONSchemaProps {Type : "string" }},
122
122
},
123
123
},
124
124
},
@@ -131,67 +131,67 @@ var _ = Describe("CRD Generation", func() {
131
131
})
132
132
133
133
It ("should replace per-version subresources with top-level subresources if only one version" , func () {
134
- spec := & apiext .CustomResourceDefinition {
135
- Spec : apiext .CustomResourceDefinitionSpec {
136
- Versions : []apiext .CustomResourceDefinitionVersion {
134
+ spec := & apiextlegacy .CustomResourceDefinition {
135
+ Spec : apiextlegacy .CustomResourceDefinitionSpec {
136
+ Versions : []apiextlegacy .CustomResourceDefinitionVersion {
137
137
{
138
138
Name : "v1" ,
139
139
Storage : true ,
140
- Subresources : & apiext .CustomResourceSubresources {
141
- Status : & apiext .CustomResourceSubresourceStatus {},
140
+ Subresources : & apiextlegacy .CustomResourceSubresources {
141
+ Status : & apiextlegacy .CustomResourceSubresourceStatus {},
142
142
},
143
143
},
144
144
},
145
145
},
146
146
}
147
147
148
148
crd .MergeIdenticalVersionInfo (spec )
149
- Expect (spec .Spec .Subresources ).To (Equal (& apiext .CustomResourceSubresources {
150
- Status : & apiext .CustomResourceSubresourceStatus {},
149
+ Expect (spec .Spec .Subresources ).To (Equal (& apiextlegacy .CustomResourceSubresources {
150
+ Status : & apiextlegacy .CustomResourceSubresourceStatus {},
151
151
}))
152
- Expect (spec .Spec .Versions ).To (Equal ([]apiext .CustomResourceDefinitionVersion {
152
+ Expect (spec .Spec .Versions ).To (Equal ([]apiextlegacy .CustomResourceDefinitionVersion {
153
153
{Name : "v1" , Storage : true },
154
154
}))
155
155
})
156
156
157
157
It ("should replace per-version subresources with top-level subresources if all are identical" , func () {
158
- spec := & apiext .CustomResourceDefinition {
159
- Spec : apiext .CustomResourceDefinitionSpec {
160
- Versions : []apiext .CustomResourceDefinitionVersion {
158
+ spec := & apiextlegacy .CustomResourceDefinition {
159
+ Spec : apiextlegacy .CustomResourceDefinitionSpec {
160
+ Versions : []apiextlegacy .CustomResourceDefinitionVersion {
161
161
{
162
162
Name : "v1" ,
163
- Subresources : & apiext .CustomResourceSubresources {
164
- Status : & apiext .CustomResourceSubresourceStatus {},
163
+ Subresources : & apiextlegacy .CustomResourceSubresources {
164
+ Status : & apiextlegacy .CustomResourceSubresourceStatus {},
165
165
},
166
166
},
167
167
{
168
168
Name : "v2" ,
169
169
Storage : true ,
170
- Subresources : & apiext .CustomResourceSubresources {
171
- Status : & apiext .CustomResourceSubresourceStatus {},
170
+ Subresources : & apiextlegacy .CustomResourceSubresources {
171
+ Status : & apiextlegacy .CustomResourceSubresourceStatus {},
172
172
},
173
173
},
174
174
},
175
175
},
176
176
}
177
177
178
178
crd .MergeIdenticalVersionInfo (spec )
179
- Expect (spec .Spec .Subresources ).To (Equal (& apiext .CustomResourceSubresources {
180
- Status : & apiext .CustomResourceSubresourceStatus {},
179
+ Expect (spec .Spec .Subresources ).To (Equal (& apiextlegacy .CustomResourceSubresources {
180
+ Status : & apiextlegacy .CustomResourceSubresourceStatus {},
181
181
}))
182
- Expect (spec .Spec .Versions ).To (Equal ([]apiext .CustomResourceDefinitionVersion {
182
+ Expect (spec .Spec .Versions ).To (Equal ([]apiextlegacy .CustomResourceDefinitionVersion {
183
183
{Name : "v1" }, {Name : "v2" , Storage : true },
184
184
}))
185
185
})
186
186
187
187
It ("shouldn't merge different subresources" , func () {
188
- spec := & apiext .CustomResourceDefinition {
189
- Spec : apiext .CustomResourceDefinitionSpec {
190
- Versions : []apiext .CustomResourceDefinitionVersion {
188
+ spec := & apiextlegacy .CustomResourceDefinition {
189
+ Spec : apiextlegacy .CustomResourceDefinitionSpec {
190
+ Versions : []apiextlegacy .CustomResourceDefinitionVersion {
191
191
{
192
192
Name : "v1" ,
193
- Subresources : & apiext .CustomResourceSubresources {
194
- Status : & apiext .CustomResourceSubresourceStatus {},
193
+ Subresources : & apiextlegacy .CustomResourceSubresources {
194
+ Status : & apiextlegacy .CustomResourceSubresourceStatus {},
195
195
},
196
196
},
197
197
{
@@ -207,13 +207,13 @@ var _ = Describe("CRD Generation", func() {
207
207
})
208
208
209
209
It ("should replace per-version printer columns with top-level printer columns if only one version" , func () {
210
- spec := & apiext .CustomResourceDefinition {
211
- Spec : apiext .CustomResourceDefinitionSpec {
212
- Versions : []apiext .CustomResourceDefinitionVersion {
210
+ spec := & apiextlegacy .CustomResourceDefinition {
211
+ Spec : apiextlegacy .CustomResourceDefinitionSpec {
212
+ Versions : []apiextlegacy .CustomResourceDefinitionVersion {
213
213
{
214
214
Name : "v1" ,
215
215
Storage : true ,
216
- AdditionalPrinterColumns : []apiext .CustomResourceColumnDefinition {
216
+ AdditionalPrinterColumns : []apiextlegacy .CustomResourceColumnDefinition {
217
217
{Name : "Cheddar" , JSONPath : ".spec.cheddar" },
218
218
{Name : "Parmesan" , JSONPath : ".status.parmesan" },
219
219
},
@@ -223,30 +223,30 @@ var _ = Describe("CRD Generation", func() {
223
223
}
224
224
225
225
crd .MergeIdenticalVersionInfo (spec )
226
- Expect (spec .Spec .AdditionalPrinterColumns ).To (Equal ([]apiext .CustomResourceColumnDefinition {
226
+ Expect (spec .Spec .AdditionalPrinterColumns ).To (Equal ([]apiextlegacy .CustomResourceColumnDefinition {
227
227
{Name : "Cheddar" , JSONPath : ".spec.cheddar" },
228
228
{Name : "Parmesan" , JSONPath : ".status.parmesan" },
229
229
}))
230
- Expect (spec .Spec .Versions ).To (Equal ([]apiext .CustomResourceDefinitionVersion {
230
+ Expect (spec .Spec .Versions ).To (Equal ([]apiextlegacy .CustomResourceDefinitionVersion {
231
231
{Name : "v1" , Storage : true },
232
232
}))
233
233
})
234
234
235
235
It ("should replace per-version printer columns with top-level printer columns if all are identical" , func () {
236
- spec := & apiext .CustomResourceDefinition {
237
- Spec : apiext .CustomResourceDefinitionSpec {
238
- Versions : []apiext .CustomResourceDefinitionVersion {
236
+ spec := & apiextlegacy .CustomResourceDefinition {
237
+ Spec : apiextlegacy .CustomResourceDefinitionSpec {
238
+ Versions : []apiextlegacy .CustomResourceDefinitionVersion {
239
239
{
240
240
Name : "v1" ,
241
- AdditionalPrinterColumns : []apiext .CustomResourceColumnDefinition {
241
+ AdditionalPrinterColumns : []apiextlegacy .CustomResourceColumnDefinition {
242
242
{Name : "Cheddar" , JSONPath : ".spec.cheddar" },
243
243
{Name : "Parmesan" , JSONPath : ".status.parmesan" },
244
244
},
245
245
},
246
246
{
247
247
Name : "v2" ,
248
248
Storage : true ,
249
- AdditionalPrinterColumns : []apiext .CustomResourceColumnDefinition {
249
+ AdditionalPrinterColumns : []apiextlegacy .CustomResourceColumnDefinition {
250
250
{Name : "Cheddar" , JSONPath : ".spec.cheddar" },
251
251
{Name : "Parmesan" , JSONPath : ".status.parmesan" },
252
252
},
@@ -256,22 +256,22 @@ var _ = Describe("CRD Generation", func() {
256
256
}
257
257
258
258
crd .MergeIdenticalVersionInfo (spec )
259
- Expect (spec .Spec .AdditionalPrinterColumns ).To (Equal ([]apiext .CustomResourceColumnDefinition {
259
+ Expect (spec .Spec .AdditionalPrinterColumns ).To (Equal ([]apiextlegacy .CustomResourceColumnDefinition {
260
260
{Name : "Cheddar" , JSONPath : ".spec.cheddar" },
261
261
{Name : "Parmesan" , JSONPath : ".status.parmesan" },
262
262
}))
263
- Expect (spec .Spec .Versions ).To (Equal ([]apiext .CustomResourceDefinitionVersion {
263
+ Expect (spec .Spec .Versions ).To (Equal ([]apiextlegacy .CustomResourceDefinitionVersion {
264
264
{Name : "v1" }, {Name : "v2" , Storage : true },
265
265
}))
266
266
})
267
267
268
268
It ("shouldn't merge different printer columns" , func () {
269
- spec := & apiext .CustomResourceDefinition {
270
- Spec : apiext .CustomResourceDefinitionSpec {
271
- Versions : []apiext .CustomResourceDefinitionVersion {
269
+ spec := & apiextlegacy .CustomResourceDefinition {
270
+ Spec : apiextlegacy .CustomResourceDefinitionSpec {
271
+ Versions : []apiextlegacy .CustomResourceDefinitionVersion {
272
272
{
273
273
Name : "v1" ,
274
- AdditionalPrinterColumns : []apiext .CustomResourceColumnDefinition {
274
+ AdditionalPrinterColumns : []apiextlegacy .CustomResourceColumnDefinition {
275
275
{Name : "Cheddar" , JSONPath : ".spec.cheddar" },
276
276
{Name : "Parmesan" , JSONPath : ".status.parmesan" },
277
277
},
0 commit comments