@@ -21,6 +21,7 @@ import (
21
21
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/bundle/source"
22
22
"github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/render"
23
23
. "github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/util/testing"
24
+ "github.com/operator-framework/operator-controller/internal/operator-controller/rukpak/util/testing/clusterserviceversion"
24
25
)
25
26
26
27
func Test_RegistryV1HelmChartProvider_Get_ReturnsBundleSourceFailures (t * testing.T ) {
@@ -51,7 +52,7 @@ func Test_RegistryV1HelmChartProvider_Get_ReturnsBundleRendererFailures(t *testi
51
52
52
53
b := source .FromBundle (
53
54
bundle.RegistryV1 {
54
- CSV : MakeCSV ( WithInstallModeSupportFor (v1alpha1 .InstallModeTypeAllNamespaces )),
55
+ CSV : clusterserviceversion . Builder (). WithInstallModeSupportFor (v1alpha1 .InstallModeTypeAllNamespaces ). Build ( ),
55
56
},
56
57
)
57
58
@@ -70,7 +71,7 @@ func Test_RegistryV1HelmChartProvider_Get_NoAPIServiceDefinitions(t *testing.T)
70
71
71
72
b := source .FromBundle (
72
73
bundle.RegistryV1 {
73
- CSV : MakeCSV ( WithOwnedAPIServiceDescriptions (v1alpha1.APIServiceDescription {})),
74
+ CSV : clusterserviceversion . Builder (). WithOwnedAPIServiceDescriptions (v1alpha1.APIServiceDescription {}). Build ( ),
74
75
},
75
76
)
76
77
@@ -85,14 +86,86 @@ func Test_RegistryV1HelmChartProvider_Get_NoAPIServiceDefinitions(t *testing.T)
85
86
require .Contains (t , err .Error (), "unsupported bundle: apiServiceDefintions are not supported" )
86
87
}
87
88
89
+ func Test_RegistryV1HelmChartProvider_Get_SingleOwnNamespace (t * testing.T ) {
90
+ t .Run ("rejects bundles without AllNamespaces install mode support if SingleOwnNamespace is not enabled" , func (t * testing.T ) {
91
+ provider := applier.RegistryV1HelmChartProvider {}
92
+
93
+ b := source .FromBundle (
94
+ bundle.RegistryV1 {
95
+ CSV : clusterserviceversion .Builder ().WithInstallModeSupportFor (v1alpha1 .InstallModeTypeOwnNamespace ).Build (),
96
+ },
97
+ )
98
+
99
+ ext := & ocv1.ClusterExtension {
100
+ Spec : ocv1.ClusterExtensionSpec {
101
+ Namespace : "install-namespace" ,
102
+ },
103
+ }
104
+
105
+ _ , err := provider .Get (b , ext )
106
+ require .Error (t , err )
107
+ require .Contains (t , err .Error (), "unsupported bundle: bundle does not support AllNamespaces install mode" )
108
+ })
109
+ t .Run ("accepts bundles with SingleNamespace install mode support if SingleOwnNamespace is enabled" , func (t * testing.T ) {
110
+ // TODO: this will be removed in a follow-up PR that will refactor GetWatchNamespace's location
111
+ featuregatetesting .SetFeatureGateDuringTest (t , features .OperatorControllerFeatureGate , features .SingleOwnNamespaceInstallSupport , true )
112
+ provider := applier.RegistryV1HelmChartProvider {
113
+ IsSingleOwnNamespaceEnabled : true ,
114
+ }
115
+
116
+ b := source .FromBundle (
117
+ bundle.RegistryV1 {
118
+ CSV : clusterserviceversion .Builder ().WithInstallModeSupportFor (v1alpha1 .InstallModeTypeSingleNamespace ).Build (),
119
+ },
120
+ )
121
+
122
+ ext := & ocv1.ClusterExtension {
123
+ Spec : ocv1.ClusterExtensionSpec {
124
+ Namespace : "install-namespace" ,
125
+ Config : & ocv1.ClusterExtensionConfig {
126
+ ConfigType : ocv1 .ClusterExtensionConfigTypeInline ,
127
+ Inline : & apiextensionsv1.JSON {
128
+ Raw : []byte (`{"watchNamespace": "some-namespace"}` ),
129
+ },
130
+ },
131
+ },
132
+ }
133
+
134
+ _ , err := provider .Get (b , ext )
135
+ require .NoError (t , err )
136
+ })
137
+ t .Run ("accepts bundles with OwnNamespace install mode support if SingleOwnNamespace is enabled" , func (t * testing.T ) {
138
+ // TODO: this will be removed in a follow-up PR that will refactor GetWatchNamespace's location
139
+ featuregatetesting .SetFeatureGateDuringTest (t , features .OperatorControllerFeatureGate , features .SingleOwnNamespaceInstallSupport , true )
140
+ provider := applier.RegistryV1HelmChartProvider {
141
+ IsSingleOwnNamespaceEnabled : true ,
142
+ }
143
+
144
+ b := source .FromBundle (
145
+ bundle.RegistryV1 {
146
+ CSV : clusterserviceversion .Builder ().WithInstallModeSupportFor (v1alpha1 .InstallModeTypeOwnNamespace ).Build (),
147
+ },
148
+ )
149
+
150
+ ext := & ocv1.ClusterExtension {
151
+ Spec : ocv1.ClusterExtensionSpec {
152
+ Namespace : "install-namespace" ,
153
+ },
154
+ }
155
+
156
+ _ , err := provider .Get (b , ext )
157
+ require .NoError (t , err )
158
+ })
159
+ }
160
+
88
161
func Test_RegistryV1HelmChartProvider_Get_NoWebhooksWithoutCertProvider (t * testing.T ) {
89
162
provider := applier.RegistryV1HelmChartProvider {
90
163
IsWebhookSupportEnabled : true ,
91
164
}
92
165
93
166
b := source .FromBundle (
94
167
bundle.RegistryV1 {
95
- CSV : MakeCSV ( WithWebhookDefinitions (v1alpha1.WebhookDescription {})),
168
+ CSV : clusterserviceversion . Builder (). WithWebhookDefinitions (v1alpha1.WebhookDescription {}). Build ( ),
96
169
},
97
170
)
98
171
@@ -114,7 +187,7 @@ func Test_RegistryV1HelmChartProvider_Get_WebhooksSupportDisabled(t *testing.T)
114
187
115
188
b := source .FromBundle (
116
189
bundle.RegistryV1 {
117
- CSV : MakeCSV ( WithWebhookDefinitions (v1alpha1.WebhookDescription {})),
190
+ CSV : clusterserviceversion . Builder (). WithWebhookDefinitions (v1alpha1.WebhookDescription {}). Build ( ),
118
191
},
119
192
)
120
193
@@ -137,10 +210,9 @@ func Test_RegistryV1HelmChartProvider_Get_WebhooksWithCertProvider(t *testing.T)
137
210
138
211
b := source .FromBundle (
139
212
bundle.RegistryV1 {
140
- CSV : MakeCSV (
141
- WithInstallModeSupportFor (v1alpha1 .InstallModeTypeAllNamespaces ),
142
- WithWebhookDefinitions (v1alpha1.WebhookDescription {}),
143
- ),
213
+ CSV : clusterserviceversion .Builder ().
214
+ WithInstallModeSupportFor (v1alpha1 .InstallModeTypeAllNamespaces ).
215
+ WithWebhookDefinitions (v1alpha1.WebhookDescription {}).Build (),
144
216
},
145
217
)
146
218
@@ -173,7 +245,7 @@ func Test_RegistryV1HelmChartProvider_Get_BundleRendererIntegration(t *testing.T
173
245
174
246
b := source .FromBundle (
175
247
bundle.RegistryV1 {
176
- CSV : MakeCSV ( WithInstallModeSupportFor (v1alpha1 .InstallModeTypeAllNamespaces , v1alpha1 .InstallModeTypeSingleNamespace )),
248
+ CSV : clusterserviceversion . Builder (). WithInstallModeSupportFor (v1alpha1 .InstallModeTypeAllNamespaces , v1alpha1 .InstallModeTypeSingleNamespace ). Build ( ),
177
249
},
178
250
)
179
251
@@ -243,10 +315,9 @@ func Test_RegistryV1HelmChartProvider_Get_Success(t *testing.T) {
243
315
244
316
b := source .FromBundle (
245
317
bundle.RegistryV1 {
246
- CSV : MakeCSV (
247
- WithAnnotations (map [string ]string {"foo" : "bar" }),
248
- WithInstallModeSupportFor (v1alpha1 .InstallModeTypeAllNamespaces ),
249
- ),
318
+ CSV : clusterserviceversion .Builder ().
319
+ WithAnnotations (map [string ]string {"foo" : "bar" }).
320
+ WithInstallModeSupportFor (v1alpha1 .InstallModeTypeAllNamespaces ).Build (),
250
321
Others : []unstructured.Unstructured {
251
322
* ToUnstructuredT (t , & corev1.Service {
252
323
TypeMeta : metav1.TypeMeta {
0 commit comments