diff --git a/api/v1/clusterextension_types.go b/api/v1/clusterextension_types.go index 6de62b0e1..e1cb0305d 100644 --- a/api/v1/clusterextension_types.go +++ b/api/v1/clusterextension_types.go @@ -176,12 +176,14 @@ type ClusterExtensionConfig struct { // inline contains JSON or YAML values specified directly in the // ClusterExtension. // - // inline must be set if configType is 'Inline'. - // inline accepts arbitrary JSON/YAML objects. - // inline is validation at runtime against the schema provided by the bundle if a schema is provided. + // inline is used to specify arbitrary configuration values for the ClusterExtension. + // It must be set if configType is 'Inline' and must be a valid JSON/YAML object containing at least one property. + // The configuration values are validated at runtime against a JSON schema provided by the bundle. // // +kubebuilder:validation:Type=object + // +kubebuilder:validation:MinProperties=1 // +optional + // +unionMember Inline *apiextensionsv1.JSON `json:"inline,omitempty"` } diff --git a/docs/api-reference/olmv1-api-reference.md b/docs/api-reference/olmv1-api-reference.md index 317b46a00..7c98cc48f 100644 --- a/docs/api-reference/olmv1-api-reference.md +++ b/docs/api-reference/olmv1-api-reference.md @@ -254,7 +254,7 @@ _Appears in:_ | Field | Description | Default | Validation | | --- | --- | --- | --- | | `configType` _[ClusterExtensionConfigType](#clusterextensionconfigtype)_ | configType is a required reference to the type of configuration source.
Allowed values are "Inline"
When this field is set to "Inline", the cluster extension configuration is defined inline within the
ClusterExtension resource. | | Enum: [Inline]
Required: \{\}
| -| `inline` _[JSON](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#json-v1-apiextensions-k8s-io)_ | inline contains JSON or YAML values specified directly in the
ClusterExtension.
inline must be set if configType is 'Inline'.
inline accepts arbitrary JSON/YAML objects.
inline is validation at runtime against the schema provided by the bundle if a schema is provided. | | Type: object
| +| `inline` _[JSON](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#json-v1-apiextensions-k8s-io)_ | inline contains JSON or YAML values specified directly in the
ClusterExtension.
inline is used to specify arbitrary configuration values for the ClusterExtension.
It must be set if configType is 'Inline' and must be a valid JSON/YAML object containing at least one property.
The configuration values are validated at runtime against a JSON schema provided by the bundle. | | MinProperties: 1
Type: object
| #### ClusterExtensionConfigType diff --git a/helm/olmv1/base/operator-controller/crd/experimental/olm.operatorframework.io_clusterextensions.yaml b/helm/olmv1/base/operator-controller/crd/experimental/olm.operatorframework.io_clusterextensions.yaml index 1038b7fdf..5f6507647 100644 --- a/helm/olmv1/base/operator-controller/crd/experimental/olm.operatorframework.io_clusterextensions.yaml +++ b/helm/olmv1/base/operator-controller/crd/experimental/olm.operatorframework.io_clusterextensions.yaml @@ -83,9 +83,10 @@ spec: inline contains JSON or YAML values specified directly in the ClusterExtension. - inline must be set if configType is 'Inline'. - inline accepts arbitrary JSON/YAML objects. - inline is validation at runtime against the schema provided by the bundle if a schema is provided. + inline is used to specify arbitrary configuration values for the ClusterExtension. + It must be set if configType is 'Inline' and must be a valid JSON/YAML object containing at least one property. + The configuration values are validated at runtime against a JSON schema provided by the bundle. + minProperties: 1 type: object x-kubernetes-preserve-unknown-fields: true required: diff --git a/internal/operator-controller/controllers/clusterextension_admission_test.go b/internal/operator-controller/controllers/clusterextension_admission_test.go index 38c6c60d4..2f8791999 100644 --- a/internal/operator-controller/controllers/clusterextension_admission_test.go +++ b/internal/operator-controller/controllers/clusterextension_admission_test.go @@ -462,9 +462,18 @@ func Test_ClusterExtensionAdmissionInlineConfig(t *testing.T) { errMsg: "spec.config.inline in body must be of type object", }, { - name: "accepts valid json object", + name: "rejects empty json object", + configBytes: []byte(`{}`), + errMsg: "spec.config.inline in body should have at least 1 properties", + }, + { + name: "accepts valid json object with configuration", configBytes: []byte(`{"key": "value"}`), }, + { + name: "accepts valid json object with nested configuration", + configBytes: []byte(`{"key": {"foo": ["bar", "baz"], "h4x0r": 1337}}`), + }, } { t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/manifests/experimental-e2e.yaml b/manifests/experimental-e2e.yaml index e536cd72a..fb2900e33 100644 --- a/manifests/experimental-e2e.yaml +++ b/manifests/experimental-e2e.yaml @@ -981,9 +981,10 @@ spec: inline contains JSON or YAML values specified directly in the ClusterExtension. - inline must be set if configType is 'Inline'. - inline accepts arbitrary JSON/YAML objects. - inline is validation at runtime against the schema provided by the bundle if a schema is provided. + inline is used to specify arbitrary configuration values for the ClusterExtension. + It must be set if configType is 'Inline' and must be a valid JSON/YAML object containing at least one property. + The configuration values are validated at runtime against a JSON schema provided by the bundle. + minProperties: 1 type: object x-kubernetes-preserve-unknown-fields: true required: diff --git a/manifests/experimental.yaml b/manifests/experimental.yaml index f88debab0..d98866c43 100644 --- a/manifests/experimental.yaml +++ b/manifests/experimental.yaml @@ -946,9 +946,10 @@ spec: inline contains JSON or YAML values specified directly in the ClusterExtension. - inline must be set if configType is 'Inline'. - inline accepts arbitrary JSON/YAML objects. - inline is validation at runtime against the schema provided by the bundle if a schema is provided. + inline is used to specify arbitrary configuration values for the ClusterExtension. + It must be set if configType is 'Inline' and must be a valid JSON/YAML object containing at least one property. + The configuration values are validated at runtime against a JSON schema provided by the bundle. + minProperties: 1 type: object x-kubernetes-preserve-unknown-fields: true required: