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
19
19
import (
20
20
"context"
21
21
"strconv"
22
+ "strings"
22
23
"time"
23
24
24
25
olmv1 "github.com/operator-framework/api/pkg/operators/v1"
@@ -420,6 +421,33 @@ func (b *Bootstrap) CreateNsScopeConfigmap() error {
420
421
return nil
421
422
}
422
423
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
+
423
451
func (b * Bootstrap ) deleteSubscription (name , namespace string ) error {
424
452
key := types.NamespacedName {Name : name , Namespace : namespace }
425
453
sub := & olmv1alpha1.Subscription {}
Original file line number Diff line number Diff line change @@ -229,3 +229,17 @@ spec:
229
229
memory: 200Mi
230
230
terminationGracePeriodSeconds: 10
231
231
`
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 5
5
require (
6
6
github.com/IBM/ibm-namespace-scope-operator v1.0.1
7
7
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
9
9
github.com/onsi/ginkgo v1.12.1
10
10
github.com/onsi/gomega v1.10.1
11
11
github.com/operator-framework/api v0.3.10
Original file line number Diff line number Diff line change @@ -105,6 +105,8 @@ func main() {
105
105
klog .Errorf ("Failed to create Namespace Scope ConfigMap: %v" , err )
106
106
os .Exit (1 )
107
107
}
108
+
109
+ go bs .CreateSecretshareCR (operatorNs , bs .MasterNamespace )
108
110
}
109
111
110
112
if operatorNs == bs .MasterNamespace || operatorNs == constant .ClusterOperatorNamespace {
You can’t perform that action at this time.
0 commit comments