@@ -188,6 +188,66 @@ func Test_RegistryV1ManifestProvider_WebhookSupport(t *testing.T) {
188188 })
189189}
190190
191+ func Test_RegistryV1ManifestProvider_ConfigUnmarshalling (t * testing.T ) {
192+ for _ , tc := range []struct {
193+ name string
194+ configBytes []byte
195+ expectedErrMessage string
196+ }{
197+ {
198+ name : "accepts json config" ,
199+ configBytes : []byte (`{"watchNamespace": "some-namespace"}` ),
200+ },
201+ {
202+ name : "accepts yaml config" ,
203+ configBytes : []byte (`watchNamespace: some-namespace` ),
204+ },
205+ {
206+ name : "rejects invalid json" ,
207+ configBytes : []byte (`{"hello` ),
208+ expectedErrMessage : `inline config is not a valid JSON/YAML object` ,
209+ },
210+ {
211+ name : "rejects valid json that isn't of object type" ,
212+ configBytes : []byte (`true` ),
213+ expectedErrMessage : `inline config is not a valid JSON/YAML object` ,
214+ },
215+ } {
216+ t .Run (tc .name , func (t * testing.T ) {
217+ provider := applier.RegistryV1ManifestProvider {
218+ BundleRenderer : render.BundleRenderer {
219+ ResourceGenerators : []render.ResourceGenerator {
220+ func (rv1 * bundle.RegistryV1 , opts render.Options ) ([]client.Object , error ) {
221+ return nil , nil
222+ },
223+ },
224+ },
225+ IsSingleOwnNamespaceEnabled : true ,
226+ }
227+
228+ bundleFS := bundlefs .Builder ().WithPackageName ("test" ).
229+ WithCSV (clusterserviceversion .Builder ().WithInstallModeSupportFor (v1alpha1 .InstallModeTypeSingleNamespace ).Build ()).Build ()
230+
231+ _ , err := provider .Get (bundleFS , & ocv1.ClusterExtension {
232+ Spec : ocv1.ClusterExtensionSpec {
233+ Namespace : "install-namespace" ,
234+ Config : & ocv1.ClusterExtensionConfig {
235+ ConfigType : ocv1 .ClusterExtensionConfigTypeInline ,
236+ Inline : & apiextensionsv1.JSON {
237+ Raw : tc .configBytes ,
238+ },
239+ },
240+ },
241+ })
242+ if tc .expectedErrMessage != "" {
243+ require .Contains (t , err .Error (), tc .expectedErrMessage )
244+ } else {
245+ require .NoError (t , err )
246+ }
247+ })
248+ }
249+ }
250+
191251func Test_RegistryV1ManifestProvider_SingleOwnNamespaceSupport (t * testing.T ) {
192252 t .Run ("rejects bundles without AllNamespaces install mode when Single/OwnNamespace install mode support is disabled" , func (t * testing.T ) {
193253 provider := applier.RegistryV1ManifestProvider {
0 commit comments