File tree Expand file tree Collapse file tree 4 files changed +45
-1
lines changed Expand file tree Collapse file tree 4 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ package bootstrap
1919import  (
2020	"context" 
2121	"strconv" 
22+ 	"strings" 
2223	"time" 
2324
2425	olmv1 "github.com/operator-framework/api/pkg/operators/v1" 
@@ -420,6 +421,33 @@ func (b *Bootstrap) CreateNsScopeConfigmap() error {
420421	return  nil 
421422}
422423
424+ // CreateNsScopeConfigmap creates nss configmap for operators 
425+ func  (b  * Bootstrap ) CreateSecretshareCR (namespace , masterNamespace  string ) {
426+ 	klog .Info ("Creating secretshare CR for entitlement registry secret" )
427+ 	dc  :=  discovery .NewDiscoveryClientForConfigOrDie (b .Config )
428+ 	for  {
429+ 		exist , err  :=  resourceExists (dc , "ibmcpcs.ibm.com/v1" , "SecretShare" )
430+ 		if  err  !=  nil  {
431+ 			klog .Error (err )
432+ 			time .Sleep (20  *  time .Second )
433+ 			continue 
434+ 		}
435+ 		if  ! exist  {
436+ 			klog .Info ("Waiting for SecretShare CRD deployed" )
437+ 			time .Sleep (20  *  time .Second )
438+ 			continue 
439+ 		}
440+ 		entitlementCR  :=  strings .ReplaceAll (constant .SecretshareEntitlementCR , "CR_NAMESPACE" , namespace )
441+ 		entitlementCR  =  strings .ReplaceAll (entitlementCR , "MASTER_NAMESPACE" , masterNamespace )
442+ 		if  err  :=  b .createOrUpdateFromYaml ([]byte (entitlementCR )); err  !=  nil  {
443+ 			klog .Error (err )
444+ 			time .Sleep (20  *  time .Second )
445+ 			continue 
446+ 		}
447+ 		break 
448+ 	}
449+ }
450+ 
423451func  (b  * Bootstrap ) deleteSubscription (name , namespace  string ) error  {
424452	key  :=  types.NamespacedName {Name : name , Namespace : namespace }
425453	sub  :=  & olmv1alpha1.Subscription {}
Original file line number Diff line number Diff line change @@ -229,3 +229,17 @@ spec:
229229            memory: 200Mi 
230230      terminationGracePeriodSeconds: 10 
231231` 
232+ 
233+ // Secretshare Operator CR for entitle registry 
234+ const  SecretshareEntitlementCR  =  ` 
235+ apiVersion: ibmcpcs.ibm.com/v1 
236+ kind: SecretShare 
237+ metadata: 
238+   name: ibm-entitlement-key 
239+   namespace: CR_NAMESPACE 
240+ spec: 
241+   secretshares: 
242+     - secretname: ibm-entitlement-key 
243+       sharewith: 
244+         - namespace: MASTER_NAMESPACE 
245+ ` 
Original file line number Diff line number Diff line change 55require  (
66	github.com/IBM/ibm-namespace-scope-operator  v1.0.1 
77	github.com/ghodss/yaml  v1.0.0 
8- 	github.com/mohae/deepcopy  v0.0.0-20170929034955-c48cc78d4826   //  indirect 
8+ 	github.com/mohae/deepcopy  v0.0.0-20170929034955-c48cc78d4826 
99	github.com/onsi/ginkgo  v1.12.1 
1010	github.com/onsi/gomega  v1.10.1 
1111	github.com/operator-framework/api  v0.3.10 
Original file line number Diff line number Diff line change @@ -105,6 +105,8 @@ func main() {
105105			klog .Errorf ("Failed to create Namespace Scope ConfigMap: %v" , err )
106106			os .Exit (1 )
107107		}
108+ 
109+ 		go  bs .CreateSecretshareCR (operatorNs , bs .MasterNamespace )
108110	}
109111
110112	if  operatorNs  ==  bs .MasterNamespace  ||  operatorNs  ==  constant .ClusterOperatorNamespace  {
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments