Skip to content

Commit 6b65cca

Browse files
author
Per Goncalves da Silva
committed
Update inline config docs and annotations
Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
1 parent 34394ce commit 6b65cca

File tree

6 files changed

+28
-14
lines changed

6 files changed

+28
-14
lines changed

api/v1/clusterextension_types.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,14 @@ type ClusterExtensionConfig struct {
176176
// inline contains JSON or YAML values specified directly in the
177177
// ClusterExtension.
178178
//
179-
// inline must be set if configType is 'Inline'.
180-
// inline accepts arbitrary JSON/YAML objects.
181-
// inline is validation at runtime against the schema provided by the bundle if a schema is provided.
179+
// inline is used to specify arbitrary configuration values for the ClusterExtension.
180+
// It must be set if configType is 'Inline' and must be a valid JSON/YAML object containing at least one property.
181+
// The configuration values are validated at runtime against a JSON schema provided by the bundle.
182182
//
183183
// +kubebuilder:validation:Type=object
184+
// +kubebuilder:validation:MinProperties=1
184185
// +optional
186+
// +unionMember
185187
Inline *apiextensionsv1.JSON `json:"inline,omitempty"`
186188
}
187189

docs/api-reference/olmv1-api-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ _Appears in:_
254254
| Field | Description | Default | Validation |
255255
| --- | --- | --- | --- |
256256
| `configType` _[ClusterExtensionConfigType](#clusterextensionconfigtype)_ | configType is a required reference to the type of configuration source.<br />Allowed values are "Inline"<br />When this field is set to "Inline", the cluster extension configuration is defined inline within the<br />ClusterExtension resource. | | Enum: [Inline] <br />Required: \{\} <br /> |
257-
| `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<br />ClusterExtension.<br />inline must be set if configType is 'Inline'.<br />inline accepts arbitrary JSON/YAML objects.<br />inline is validation at runtime against the schema provided by the bundle if a schema is provided. | | Type: object <br /> |
257+
| `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<br />ClusterExtension.<br />inline is used to specify arbitrary configuration values for the ClusterExtension.<br />It must be set if configType is 'Inline' and must be a valid JSON/YAML object containing at least one property.<br />The configuration values are validated at runtime against a JSON schema provided by the bundle. | | MinProperties: 1 <br />Type: object <br /> |
258258

259259

260260
#### ClusterExtensionConfigType

helm/olmv1/base/operator-controller/crd/experimental/olm.operatorframework.io_clusterextensions.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ spec:
8383
inline contains JSON or YAML values specified directly in the
8484
ClusterExtension.
8585
86-
inline must be set if configType is 'Inline'.
87-
inline accepts arbitrary JSON/YAML objects.
88-
inline is validation at runtime against the schema provided by the bundle if a schema is provided.
86+
inline is used to specify arbitrary configuration values for the ClusterExtension.
87+
It must be set if configType is 'Inline' and must be a valid JSON/YAML object containing at least one property.
88+
The configuration values are validated at runtime against a JSON schema provided by the bundle.
89+
minProperties: 1
8990
type: object
9091
x-kubernetes-preserve-unknown-fields: true
9192
required:

internal/operator-controller/controllers/clusterextension_admission_test.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,18 @@ func Test_ClusterExtensionAdmissionInlineConfig(t *testing.T) {
462462
errMsg: "spec.config.inline in body must be of type object",
463463
},
464464
{
465-
name: "accepts valid json object",
465+
name: "rejects empty json object",
466+
configBytes: []byte(`{}`),
467+
errMsg: "spec.config.inline in body should have at least 1 properties",
468+
},
469+
{
470+
name: "accepts valid json object with configuration",
466471
configBytes: []byte(`{"key": "value"}`),
467472
},
473+
{
474+
name: "accepts valid json object with nested configuration",
475+
configBytes: []byte(`{"key": {"foo": ["bar", "baz"], "h4x0r": 1337}}`),
476+
},
468477
} {
469478
t.Run(tc.name, func(t *testing.T) {
470479
t.Parallel()

manifests/experimental-e2e.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -981,9 +981,10 @@ spec:
981981
inline contains JSON or YAML values specified directly in the
982982
ClusterExtension.
983983
984-
inline must be set if configType is 'Inline'.
985-
inline accepts arbitrary JSON/YAML objects.
986-
inline is validation at runtime against the schema provided by the bundle if a schema is provided.
984+
inline is used to specify arbitrary configuration values for the ClusterExtension.
985+
It must be set if configType is 'Inline' and must be a valid JSON/YAML object containing at least one property.
986+
The configuration values are validated at runtime against a JSON schema provided by the bundle.
987+
minProperties: 1
987988
type: object
988989
x-kubernetes-preserve-unknown-fields: true
989990
required:

manifests/experimental.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,9 +946,10 @@ spec:
946946
inline contains JSON or YAML values specified directly in the
947947
ClusterExtension.
948948
949-
inline must be set if configType is 'Inline'.
950-
inline accepts arbitrary JSON/YAML objects.
951-
inline is validation at runtime against the schema provided by the bundle if a schema is provided.
949+
inline is used to specify arbitrary configuration values for the ClusterExtension.
950+
It must be set if configType is 'Inline' and must be a valid JSON/YAML object containing at least one property.
951+
The configuration values are validated at runtime against a JSON schema provided by the bundle.
952+
minProperties: 1
952953
type: object
953954
x-kubernetes-preserve-unknown-fields: true
954955
required:

0 commit comments

Comments
 (0)