@@ -34,7 +34,7 @@ func (rv1 *RegistryV1) GetConfigSchema() (map[string]any, error) {
3434// buildBundleConfigSchema creates validation rules based on what the operator supports.
3535//
3636// Examples of how install modes affect validation:
37- // - AllNamespaces only: user can't set watchNamespace (operator watches everything)
37+ // - AllNamespaces only: watchNamespace is explicitly rejected with helpful error
3838// - OwnNamespace only: user must set watchNamespace to the install namespace
3939// - SingleNamespace only: user must set watchNamespace to a different namespace
4040// - AllNamespaces + OwnNamespace: user can optionally set watchNamespace
@@ -48,8 +48,12 @@ func buildBundleConfigSchema(installModes sets.Set[v1alpha1.InstallMode]) (map[s
4848 properties := map [string ]any {}
4949 var required []any
5050
51- // Add watchNamespace property if the bundle supports it
52- if isWatchNamespaceConfigurable (installModes ) {
51+ // Special case: if ONLY AllNamespaces is supported, explicitly reject watchNamespace
52+ // with a helpful error message (instead of generic "unknown field")
53+ if isAllNamespacesOnly (installModes ) {
54+ properties ["watchNamespace" ] = buildRejectedWatchNamespaceProperty ()
55+ } else if isWatchNamespaceConfigurable (installModes ) {
56+ // Add watchNamespace property if the bundle supports it
5357 watchNSProperty , isRequired := buildWatchNamespaceProperty (installModes )
5458 properties ["watchNamespace" ] = watchNSProperty
5559 if isRequired {
@@ -151,3 +155,27 @@ func isWatchNamespaceConfigRequired(installModes sets.Set[v1alpha1.InstallMode])
151155 return isWatchNamespaceConfigurable (installModes ) &&
152156 ! installModes .Has (v1alpha1.InstallMode {Type : v1alpha1 .InstallModeTypeAllNamespaces , Supported : true })
153157}
158+
159+ // isAllNamespacesOnly checks if only AllNamespaces install mode is supported.
160+ //
161+ // Returns true when:
162+ // - Only AllNamespaces is supported (no OwnNamespace, no SingleNamespace)
163+ //
164+ // Returns false when:
165+ // - OwnNamespace or SingleNamespace is also supported
166+ func isAllNamespacesOnly (installModes sets.Set [v1alpha1.InstallMode ]) bool {
167+ hasAllNamespaces := installModes .Has (v1alpha1.InstallMode {Type : v1alpha1 .InstallModeTypeAllNamespaces , Supported : true })
168+ hasConfigurable := isWatchNamespaceConfigurable (installModes )
169+
170+ return hasAllNamespaces && ! hasConfigurable
171+ }
172+
173+ // buildRejectedWatchNamespaceProperty creates a schema property that always rejects
174+ // watchNamespace with a descriptive error message for AllNamespaces-only operators.
175+ func buildRejectedWatchNamespaceProperty () map [string ]any {
176+ return map [string ]any {
177+ "type" : "string" ,
178+ "format" : config .FormatAllNamespacesOnlyInstallMode ,
179+ "description" : "This field is not supported for this operator's install mode configuration" ,
180+ }
181+ }
0 commit comments