Skip to content

Commit c8b148c

Browse files
committed
OCPBUGS-45295: Make plugins name array items unique
1 parent c1fdeb0 commit c8b148c

File tree

6 files changed

+46
-1
lines changed

6 files changed

+46
-1
lines changed

openapi/generated_openapi/zz_generated.openapi.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openapi/openapi.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -27015,7 +27015,8 @@
2701527015
"items": {
2701627016
"type": "string",
2701727017
"default": ""
27018-
}
27018+
},
27019+
"x-kubernetes-list-type": "atomic"
2701927020
},
2702027021
"providers": {
2702127022
"description": "providers contains configuration for using specific service providers.",

operator/v1/tests/consoles.operator.openshift.io/AAA_ungated.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,29 @@ tests:
296296
visibility:
297297
state: Enables
298298
expectedError: "spec.customization.capabilities[0].visibility.state: Unsupported value: \"Enables\": supported values: \"Enabled\", \"Disabled\""
299+
- name: Should be able to create a Console with multiple plugins
300+
initial: |
301+
apiVersion: operator.openshift.io/v1
302+
kind: Console
303+
spec:
304+
plugins:
305+
- test-plugin-1
306+
- test-plugin-2
307+
expected: |
308+
apiVersion: operator.openshift.io/v1
309+
kind: Console
310+
spec:
311+
logLevel: Normal
312+
operatorLogLevel: Normal
313+
plugins:
314+
- test-plugin-1
315+
- test-plugin-2
316+
- name: Should throw an error for duplicate plugin name
317+
initial: |
318+
apiVersion: operator.openshift.io/v1
319+
kind: Console
320+
spec:
321+
plugins:
322+
- test-plugin-1
323+
- test-plugin-1
324+
expectedError: "spec.plugins: Invalid value: \"array\": each plugin name must be unique"

operator/v1/types_console.go

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ type ConsoleSpec struct {
5555
// +optional
5656
Route ConsoleConfigRoute `json:"route"`
5757
// plugins defines a list of enabled console plugin names.
58+
// +listType=atomic
59+
// +kubebuilder:validation:MaxItems=64
60+
// +kubebuilder:validation:XValidation:rule="self.all(x, self.exists_one(y, x == y))",message="each plugin name must be unique"
5861
// +optional
5962
Plugins []string `json:"plugins,omitempty"`
6063
// ingress allows to configure the alternative ingress for the console.

operator/v1/zz_generated.crd-manifests/0000_50_console_01_consoles.crd.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,12 @@ spec:
780780
description: plugins defines a list of enabled console plugin names.
781781
items:
782782
type: string
783+
maxItems: 64
783784
type: array
785+
x-kubernetes-list-type: atomic
786+
x-kubernetes-validations:
787+
- message: each plugin name must be unique
788+
rule: self.all(x, self.exists_one(y, x == y))
784789
providers:
785790
description: providers contains configuration for using specific service
786791
providers.

operator/v1/zz_generated.featuregated-crd-manifests/consoles.operator.openshift.io/AAA_ungated.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,12 @@ spec:
781781
description: plugins defines a list of enabled console plugin names.
782782
items:
783783
type: string
784+
maxItems: 64
784785
type: array
786+
x-kubernetes-list-type: atomic
787+
x-kubernetes-validations:
788+
- message: each plugin name must be unique
789+
rule: self.all(x, self.exists_one(y, x == y))
785790
providers:
786791
description: providers contains configuration for using specific service
787792
providers.

0 commit comments

Comments
 (0)