@@ -532,6 +532,29 @@ func (s *TestSuite) beforeSuiteForIntegrationTesting() {
532
532
Expect (s .config ).ToNot (BeNil ())
533
533
})
534
534
535
+ By ("updating image registry CRD storage version" , func () {
536
+ // Update storage version of ContentLibraryItems if necessary
537
+ cliCrd := s .GetInstalledCRD ("contentlibraryitems.imageregistry.vmware.com" )
538
+ Expect (cliCrd ).ToNot (BeNil ())
539
+ s .UpdateCRDStorage (cliCrd )
540
+ // Update storage version of ClusterContentLibraryItems if necessary
541
+ ccliCrd := s .GetInstalledCRD ("clustercontentlibraryitems.imageregistry.vmware.com" )
542
+ Expect (ccliCrd ).ToNot (BeNil ())
543
+ s .UpdateCRDStorage (ccliCrd )
544
+ // Update storage version of ContentLibraries if necessary
545
+ clCrd := s .GetInstalledCRD ("contentlibraries.imageregistry.vmware.com" )
546
+ Expect (clCrd ).ToNot (BeNil ())
547
+ s .UpdateCRDStorage (clCrd )
548
+ // Update storage version of ClusterContentLibraries if necessary
549
+ cclCrd := s .GetInstalledCRD ("clustercontentlibraries.imageregistry.vmware.com" )
550
+ Expect (cclCrd ).ToNot (BeNil ())
551
+ s .UpdateCRDStorage (cclCrd )
552
+ // Update storage version of ContentLibraryItemImportRequests if necessary
553
+ cliImportReqCrd := s .GetInstalledCRD ("contentlibraryitemimportrequests.imageregistry.vmware.com" )
554
+ Expect (cliImportReqCrd ).ToNot (BeNil ())
555
+ s .UpdateCRDStorage (cliImportReqCrd )
556
+ })
557
+
535
558
// If one or more webhooks are being tested then go ahead and generate a
536
559
// PKI toolchain to use with the webhook server.
537
560
if s .isWebhookTest () {
@@ -631,6 +654,32 @@ func (s *TestSuite) GetInstalledCRD(crdName string) *apiextensionsv1.CustomResou
631
654
return nil
632
655
}
633
656
657
+ func (s * TestSuite ) UpdateCRDStorage (oldCrd * apiextensionsv1.CustomResourceDefinition ) {
658
+
659
+ err := envtest .UninstallCRDs (s .envTest .Config , envtest.CRDInstallOptions {
660
+ CRDs : []* apiextensionsv1.CustomResourceDefinition {oldCrd },
661
+ })
662
+ Expect (err ).ToNot (HaveOccurred ())
663
+
664
+ crds := make ([]* apiextensionsv1.CustomResourceDefinition , 0 )
665
+ updatedCrd := updateImgRegStorageVersion (s .Context , * oldCrd )
666
+
667
+ Eventually (func () error {
668
+ newCrd := & apiextensionsv1.CustomResourceDefinition {
669
+ ObjectMeta : metav1.ObjectMeta {
670
+ Name : updatedCrd .Name ,
671
+ Annotations : updatedCrd .Annotations ,
672
+ },
673
+ Spec : updatedCrd .Spec ,
674
+ }
675
+ crds , err = envtest .InstallCRDs (s .envTest .Config , envtest.CRDInstallOptions {
676
+ CRDs : []* apiextensionsv1.CustomResourceDefinition {newCrd },
677
+ })
678
+ return err
679
+ }).ShouldNot (HaveOccurred ())
680
+ s .envTest .CRDs = append (s .envTest .CRDs , crds ... )
681
+ }
682
+
634
683
func (s * TestSuite ) UpdateCRDScope (oldCrd * apiextensionsv1.CustomResourceDefinition , newScope string ) {
635
684
// crd.spec.scope is immutable, uninstall first
636
685
err := envtest .UninstallCRDs (s .envTest .Config , envtest.CRDInstallOptions {
0 commit comments