@@ -37,6 +37,7 @@ import (
37
37
k8sclientset "k8s.io/client-go/kubernetes"
38
38
openapiutil "k8s.io/kube-openapi/pkg/util"
39
39
"k8s.io/kubernetes/test/e2e/framework"
40
+ "k8s.io/kubernetes/test/utils/crd"
40
41
"sigs.k8s.io/yaml"
41
42
)
42
43
@@ -58,7 +59,7 @@ var _ = SIGDescribe("CustomResourcePublishOpenAPI [Feature:CustomResourcePublish
58
59
framework .Failf ("%v" , err )
59
60
}
60
61
61
- meta := fmt .Sprintf (metaPattern , crd .Kind , crd .ApiGroup , crd .Versions [0 ].Name , "test-foo" )
62
+ meta := fmt .Sprintf (metaPattern , crd .Kind , crd .APIGroup , crd .Versions [0 ].Name , "test-foo" )
62
63
ns := fmt .Sprintf ("--namespace=%v" , f .Namespace .Name )
63
64
64
65
By ("client-side validation (kubectl create and apply) allows request with known and required properties" )
@@ -126,7 +127,7 @@ var _ = SIGDescribe("CustomResourcePublishOpenAPI [Feature:CustomResourcePublish
126
127
framework .Failf ("%v" , err )
127
128
}
128
129
129
- meta := fmt .Sprintf (metaPattern , crd .Kind , crd .ApiGroup , crd .Versions [0 ].Name , "test-cr" )
130
+ meta := fmt .Sprintf (metaPattern , crd .Kind , crd .APIGroup , crd .Versions [0 ].Name , "test-cr" )
130
131
ns := fmt .Sprintf ("--namespace=%v" , f .Namespace .Name )
131
132
132
133
By ("client-side validation (kubectl create and apply) allows request with any unknown properties" )
@@ -164,8 +165,8 @@ var _ = SIGDescribe("CustomResourcePublishOpenAPI [Feature:CustomResourcePublish
164
165
if err != nil {
165
166
framework .Failf ("%v" , err )
166
167
}
167
- if crdFoo .ApiGroup == crdWaldo .ApiGroup {
168
- framework .Failf ("unexpected: CRDs should be of different group %v, %v" , crdFoo .ApiGroup , crdWaldo .ApiGroup )
168
+ if crdFoo .APIGroup == crdWaldo .APIGroup {
169
+ framework .Failf ("unexpected: CRDs should be of different group %v, %v" , crdFoo .APIGroup , crdWaldo .APIGroup )
169
170
}
170
171
if err := waitForDefinition (f .ClientSet , definitionName (crdWaldo , "v1beta1" ), schemaWaldo ); err != nil {
171
172
framework .Failf ("%v" , err )
@@ -206,8 +207,8 @@ var _ = SIGDescribe("CustomResourcePublishOpenAPI [Feature:CustomResourcePublish
206
207
if err != nil {
207
208
framework .Failf ("%v" , err )
208
209
}
209
- if crdFoo .ApiGroup != crdWaldo .ApiGroup {
210
- framework .Failf ("unexpected: CRDs should be of the same group %v, %v" , crdFoo .ApiGroup , crdWaldo .ApiGroup )
210
+ if crdFoo .APIGroup != crdWaldo .APIGroup {
211
+ framework .Failf ("unexpected: CRDs should be of the same group %v, %v" , crdFoo .APIGroup , crdWaldo .APIGroup )
211
212
}
212
213
if err := waitForDefinition (f .ClientSet , definitionName (crdWaldo , "v5" ), schemaWaldo ); err != nil {
213
214
framework .Failf ("%v" , err )
@@ -233,8 +234,8 @@ var _ = SIGDescribe("CustomResourcePublishOpenAPI [Feature:CustomResourcePublish
233
234
if err != nil {
234
235
framework .Failf ("%v" , err )
235
236
}
236
- if crdFoo .ApiGroup != crdWaldo .ApiGroup {
237
- framework .Failf ("unexpected: CRDs should be of the same group %v, %v" , crdFoo .ApiGroup , crdWaldo .ApiGroup )
237
+ if crdFoo .APIGroup != crdWaldo .APIGroup {
238
+ framework .Failf ("unexpected: CRDs should be of the same group %v, %v" , crdFoo .APIGroup , crdWaldo .APIGroup )
238
239
}
239
240
if err := waitForDefinition (f .ClientSet , definitionName (crdWaldo , "v6" ), schemaWaldo ); err != nil {
240
241
framework .Failf ("%v" , err )
@@ -265,7 +266,7 @@ var _ = SIGDescribe("CustomResourcePublishOpenAPI [Feature:CustomResourcePublish
265
266
266
267
By ("rename a version" )
267
268
patch := []byte (`{"spec":{"versions":[{"name":"v2","served":true,"storage":true},{"name":"v4","served":true,"storage":false}]}}` )
268
- crdMultiVer .Crd , err = crdMultiVer .ApiExtensionClient .ApiextensionsV1beta1 ().CustomResourceDefinitions ().Patch (crdMultiVer .GetMetaName (), types .MergePatchType , patch )
269
+ crdMultiVer .Crd , err = crdMultiVer .APIExtensionClient .ApiextensionsV1beta1 ().CustomResourceDefinitions ().Patch (crdMultiVer .GetMetaName (), types .MergePatchType , patch )
269
270
if err != nil {
270
271
framework .Failf ("%v" , err )
271
272
}
@@ -307,7 +308,7 @@ var _ = SIGDescribe("CustomResourcePublishOpenAPI [Feature:CustomResourcePublish
307
308
308
309
By ("mark a version not serverd" )
309
310
crd .Crd .Spec .Versions [1 ].Served = false
310
- crd .Crd , err = crd .ApiExtensionClient .ApiextensionsV1beta1 ().CustomResourceDefinitions ().Update (crd .Crd )
311
+ crd .Crd , err = crd .APIExtensionClient .ApiextensionsV1beta1 ().CustomResourceDefinitions ().Update (crd .Crd )
311
312
if err != nil {
312
313
framework .Failf ("%v" , err )
313
314
}
@@ -327,7 +328,7 @@ var _ = SIGDescribe("CustomResourcePublishOpenAPI [Feature:CustomResourcePublish
327
328
})
328
329
})
329
330
330
- func setupCRD (f * framework.Framework , schema []byte , groupSuffix string , versions ... string ) (* framework .TestCrd , error ) {
331
+ func setupCRD (f * framework.Framework , schema []byte , groupSuffix string , versions ... string ) (* crd .TestCrd , error ) {
331
332
group := fmt .Sprintf ("%s-test-%s.k8s.io" , f .BaseName , groupSuffix )
332
333
if len (versions ) == 0 {
333
334
return nil , fmt .Errorf ("require at least one version for CRD" )
@@ -343,7 +344,7 @@ func setupCRD(f *framework.Framework, schema []byte, groupSuffix string, version
343
344
}
344
345
apiVersions [0 ].Storage = true
345
346
346
- crd , err := framework .CreateMultiVersionTestCRD (f , group , apiVersions , nil )
347
+ crd , err := crd .CreateMultiVersionTestCRD (f , group , apiVersions , nil )
347
348
if err != nil {
348
349
return nil , fmt .Errorf ("failed to create CRD: %v" , err )
349
350
}
@@ -366,7 +367,7 @@ func setupCRD(f *framework.Framework, schema []byte, groupSuffix string, version
366
367
return crd , nil
367
368
}
368
369
369
- func cleanupCRD (f * framework.Framework , crd * framework .TestCrd ) error {
370
+ func cleanupCRD (f * framework.Framework , crd * crd .TestCrd ) error {
370
371
crd .CleanUp ()
371
372
for _ , v := range crd .Versions {
372
373
name := definitionName (crd , v .Name )
@@ -378,13 +379,13 @@ func cleanupCRD(f *framework.Framework, crd *framework.TestCrd) error {
378
379
}
379
380
380
381
// patchSchema takes schema in YAML and patches it to given CRD in given version
381
- func patchSchema (schema []byte , crd * framework .TestCrd ) error {
382
+ func patchSchema (schema []byte , crd * crd .TestCrd ) error {
382
383
s , err := utilyaml .ToJSON (schema )
383
384
if err != nil {
384
385
return fmt .Errorf ("failed to create json patch: %v" , err )
385
386
}
386
387
patch := []byte (fmt .Sprintf (`{"spec":{"validation":{"openAPIV3Schema":%s}}}` , string (s )))
387
- crd .Crd , err = crd .ApiExtensionClient .ApiextensionsV1beta1 ().CustomResourceDefinitions ().Patch (crd .GetMetaName (), types .MergePatchType , patch )
388
+ crd .Crd , err = crd .APIExtensionClient .ApiextensionsV1beta1 ().CustomResourceDefinitions ().Patch (crd .GetMetaName (), types .MergePatchType , patch )
388
389
return err
389
390
}
390
391
@@ -484,8 +485,8 @@ func verifyKubectlExplain(name, pattern string) error {
484
485
}
485
486
486
487
// definitionName returns the openapi definition name for given CRD in given version
487
- func definitionName (crd * framework .TestCrd , version string ) string {
488
- return openapiutil .ToRESTFriendlyName (fmt .Sprintf ("%s/%s/%s" , crd .ApiGroup , version , crd .Kind ))
488
+ func definitionName (crd * crd .TestCrd , version string ) string {
489
+ return openapiutil .ToRESTFriendlyName (fmt .Sprintf ("%s/%s/%s" , crd .APIGroup , version , crd .Kind ))
489
490
}
490
491
491
492
var schemaFoo = []byte (`description: Foo CRD for Testing
0 commit comments