6
6
"github.com/stretchr/testify/require"
7
7
corev1 "k8s.io/api/core/v1"
8
8
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
9
+ "k8s.io/apimachinery/pkg/runtime"
9
10
featuregatetesting "k8s.io/component-base/featuregate/testing"
10
11
11
12
v1 "github.com/operator-framework/operator-controller/api/v1"
@@ -17,11 +18,17 @@ func TestGetWatchNamespacesWhenFeatureGateIsDisabled(t *testing.T) {
17
18
watchNamespace , err := applier .GetWatchNamespace (& v1.ClusterExtension {
18
19
ObjectMeta : metav1.ObjectMeta {
19
20
Name : "extension" ,
20
- Annotations : map [string ]string {
21
- "olm.operatorframework.io/watch-namespace" : "watch-namespace" ,
21
+ // Annotations: map[string]string{
22
+ // "olm.operatorframework.io/watch-namespace": "watch-namespace",
23
+ // },
24
+ },
25
+ Spec : v1.ClusterExtensionSpec {
26
+ Config : []runtime.RawExtension {
27
+ {Raw : []byte (
28
+ `{"apiVersion":"olm.operatorframework.io/v1","kind":"BundleConfig",` +
29
+ `"spec":{"watchNamespace":"watch-namespace"}}` )},
22
30
},
23
31
},
24
- Spec : v1.ClusterExtensionSpec {},
25
32
})
26
33
require .NoError (t , err )
27
34
t .Log ("Check watchNamespace is '' even if the annotation is set" )
@@ -54,11 +61,14 @@ func TestGetWatchNamespace(t *testing.T) {
54
61
csv : & v1.ClusterExtension {
55
62
ObjectMeta : metav1.ObjectMeta {
56
63
Name : "extension" ,
57
- Annotations : map [string ]string {
58
- "olm.operatorframework.io/watch-namespace" : "watch-namespace" ,
64
+ },
65
+ Spec : v1.ClusterExtensionSpec {
66
+ Config : []runtime.RawExtension {
67
+ {Raw : []byte (
68
+ `{"apiVersion":"olm.operatorframework.io/v1","kind":"BundleConfig",` +
69
+ `"spec":{"watchNamespace":"watch-namespace"}}` )},
59
70
},
60
71
},
61
- Spec : v1.ClusterExtensionSpec {},
62
72
},
63
73
expectError : false ,
64
74
}, {
@@ -67,11 +77,14 @@ func TestGetWatchNamespace(t *testing.T) {
67
77
csv : & v1.ClusterExtension {
68
78
ObjectMeta : metav1.ObjectMeta {
69
79
Name : "extension" ,
70
- Annotations : map [string ]string {
71
- "olm.operatorframework.io/watch-namespace" : "watch-namespace,watch-namespace2,watch-namespace3" ,
80
+ },
81
+ Spec : v1.ClusterExtensionSpec {
82
+ Config : []runtime.RawExtension {
83
+ {Raw : []byte (
84
+ `{"apiVersion":"olm.operatorframework.io/v1","kind":"BundleConfig",` +
85
+ `"spec":{"watchNamespace":"watch-namespace,watch-namespace2,watch-namespace3"}}` )},
72
86
},
73
87
},
74
- Spec : v1.ClusterExtensionSpec {},
75
88
},
76
89
expectError : true ,
77
90
}, {
@@ -84,7 +97,13 @@ func TestGetWatchNamespace(t *testing.T) {
84
97
"olm.operatorframework.io/watch-namespace" : "watch-namespace-" ,
85
98
},
86
99
},
87
- Spec : v1.ClusterExtensionSpec {},
100
+ Spec : v1.ClusterExtensionSpec {
101
+ Config : []runtime.RawExtension {
102
+ {Raw : []byte (
103
+ `{"apiVersion":"olm.operatorframework.io/v1","kind":"BundleConfig",` +
104
+ `"spec":{"watchNamespace":"watch-namespace-"}}` )},
105
+ },
106
+ },
88
107
},
89
108
expectError : true ,
90
109
},
0 commit comments