@@ -55,17 +55,7 @@ import (
55
55
)
56
56
57
57
var (
58
- placeholder = "placeholder"
59
- OdlmNamespacedSubResource = "odlmNamespacedSubscription"
60
- OdlmClusterSubResource = "odlmClusterSubscription"
61
- RegistryCrResources = "csV3OperandRegistry"
62
- RegistrySaasCrResources = "csV3SaasOperandRegistry"
63
- ConfigCrResources = "csV3OperandConfig"
64
- ConfigSaasCrResources = "csV3SaasOperandConfig"
65
- CSOperatorVersions = map [string ]string {
66
- "operand-deployment-lifecycle-manager-app" : "1.5.0" ,
67
- "ibm-cert-manager-operator" : "3.9.0" ,
68
- }
58
+ placeholder = "placeholder"
69
59
)
70
60
71
61
var ctx = context .Background ()
@@ -636,129 +626,60 @@ func (b *Bootstrap) InstallOrUpdateOpreg(forceUpdateODLMCRs bool, installPlanApp
636
626
}
637
627
}
638
628
639
- var err error
640
- constant .CSV3OperandRegistry , err = constant .ConcatenateRegistries (constant .CSV2OpReg , constant .CSV3OpReg , b .CSData )
641
- if err != nil {
642
- klog .Errorf ("failed to concatenate registries CSV3OperandRegistry: %v" , err )
643
- }
644
- // Append CP3 Operators into CP3 OperandRegistry
629
+ var baseReg string
645
630
registries := []string {
631
+ constant .CSV3OpReg ,
646
632
constant .MongoDBOpReg ,
647
633
constant .IMOpReg ,
648
634
constant .IdpConfigUIOpReg ,
649
635
constant .PlatformUIOpReg ,
650
636
constant .KeyCloakOpReg ,
651
637
}
652
-
653
- for _ , reg := range registries {
654
- constant .CSV3OperandRegistry , err = constant .ConcatenateRegistries (constant .CSV3OperandRegistry , reg , b .CSData )
655
- if err != nil {
656
- klog .Errorf ("failed to append CP3 operators into OperandRegistry: %v" , err )
657
- }
658
- }
659
-
660
- constant .CSV3SaasOperandRegistry , err = constant .ConcatenateRegistries (constant .CSV2SaasOpReg , constant .CSV3SaasOpReg , b .CSData )
661
- if err != nil {
662
- klog .Errorf ("failed to concatenate registries CSV3SaasOperandRegistry: %v" , err )
663
- }
664
-
665
- // Append CP3 operators into CP3 SaaS OperandRegistry
666
- Saasregistries := []string {
667
- constant .MongoDBOpReg ,
668
- constant .IMOpReg ,
669
- constant .PlatformUIOpReg ,
670
- constant .KeyCloakOpReg ,
671
- }
672
-
673
- for _ , reg := range Saasregistries {
674
- constant .CSV3SaasOperandRegistry , err = constant .ConcatenateRegistries (constant .CSV3SaasOperandRegistry , reg , b .CSData )
675
- if err != nil {
676
- klog .Errorf ("failed to append CP3 operators into SaaS OperandRegistry: %v" , err )
677
- }
678
- }
679
-
680
- var obj []* unstructured.Unstructured
681
638
if b .SaasEnable {
682
- // OperandRegistry for SaaS deployment
683
- obj , err = b .GetObjs (constant .CSV3SaasOperandRegistry , b .CSData )
639
+ baseReg = constant .CSV2SaasOpReg
684
640
} else {
685
- // OperandRegistry for on-prem deployment
686
- obj , err = b .GetObjs (constant .CSV3OperandRegistry , b .CSData )
641
+ baseReg = constant .CSV2OpReg
687
642
}
643
+
644
+ concatenatedReg , err := constant .ConcatenateRegistries (baseReg , registries , b .CSData )
688
645
if err != nil {
689
- klog .Error ( err )
646
+ klog .Errorf ( "failed to concatenate OperandRegistry: %v" , err )
690
647
return err
691
648
}
692
649
693
- objInCluster , err := b .GetObject (obj [0 ])
694
- if errors .IsNotFound (err ) {
695
- klog .Infof ("Creating resource with name: %s, namespace: %s, kind: %s, apiversion: %s\n " , obj [0 ].GetName (), obj [0 ].GetNamespace (), obj [0 ].GetKind (), obj [0 ].GetAPIVersion ())
696
- if err := b .CreateObject (obj [0 ]); err != nil {
697
- klog .Error (err )
698
- return err
699
- }
700
- } else if err != nil {
701
- klog .Error (err )
650
+ if err := b .renderTemplate (concatenatedReg , b .CSData , forceUpdateODLMCRs ); err != nil {
702
651
return err
703
- } else {
704
- klog .Infof ("Updating resource with name: %s, namespace: %s, kind: %s, apiversion: %s\n " , obj [0 ].GetName (), obj [0 ].GetNamespace (), obj [0 ].GetKind (), obj [0 ].GetAPIVersion ())
705
- resourceVersion := objInCluster .GetResourceVersion ()
706
- obj [0 ].SetResourceVersion (resourceVersion )
707
- v1IsLarger , convertErr := util .CompareVersion (obj [0 ].GetAnnotations ()["version" ], objInCluster .GetAnnotations ()["version" ])
708
- if convertErr != nil {
709
- return convertErr
710
- }
711
- if v1IsLarger || forceUpdateODLMCRs {
712
- if err := b .UpdateObject (obj [0 ]); err != nil {
713
- klog .Error (err )
714
- return err
715
- }
716
- }
717
652
}
718
-
719
653
return nil
720
654
}
721
655
722
656
// InstallOrUpdateOpcon will install or update OperandConfig when Opcon CRD is existent
723
657
func (b * Bootstrap ) InstallOrUpdateOpcon (forceUpdateODLMCRs bool ) error {
724
- var err error
725
658
726
- // Append CP3 Services with suffix into CP3 and SaaS OperandConfig
727
- Configs := []string {
659
+ var baseCon string
660
+ configs := []string {
728
661
constant .MongoDBOpCon ,
729
662
constant .IMOpCon ,
730
663
constant .IdpConfigUIOpCon ,
731
664
constant .PlatformUIOpCon ,
732
665
constant .KeyCloakOpCon ,
733
666
}
734
667
735
- constant .CSV3OperandConfig = constant .CSV3OpCon
736
- constant .CSV3SaasOperandConfig = constant .CSV3SaasOpCon
737
- for _ , con := range Configs {
738
- constant .CSV3OperandConfig , err = constant .ConcatenateConfigs (constant .CSV3OperandConfig , con , b .CSData )
739
- if err != nil {
740
- klog .Errorf ("failed to append CP3 services into OperandConfig: %v" , err )
741
- return err
742
- }
743
- constant .CSV3SaasOperandConfig , err = constant .ConcatenateConfigs (constant .CSV3SaasOperandConfig , con , b .CSData )
744
- if err != nil {
745
- klog .Errorf ("failed to append CP3 services into SaaS OperandConfig: %v" , err )
746
- return err
747
- }
748
- }
749
-
750
668
if b .SaasEnable {
751
- // OperandConfig for SaaS deployment
752
- if err := b .renderTemplate (constant .CSV3SaasOperandConfig , b .CSData , forceUpdateODLMCRs ); err != nil {
753
- return err
754
- }
669
+ baseCon = constant .CSV3SaasOpCon
755
670
} else {
756
- // OperandConfig for on-prem deployment
757
- if err := b .renderTemplate (constant .CSV3OperandConfig , b .CSData , forceUpdateODLMCRs ); err != nil {
758
- return err
759
- }
671
+ baseCon = constant .CSV3OpCon
760
672
}
761
673
674
+ concatenatedCon , err := constant .ConcatenateConfigs (baseCon , configs , b .CSData )
675
+ if err != nil {
676
+ klog .Errorf ("failed to concatenate OperandConfig: %v" , err )
677
+ return err
678
+ }
679
+
680
+ if err := b .renderTemplate (concatenatedCon , b .CSData , forceUpdateODLMCRs ); err != nil {
681
+ return err
682
+ }
762
683
return nil
763
684
}
764
685
0 commit comments