Skip to content

Commit 70c33c8

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

File tree

7 files changed

+56
-3
lines changed

7 files changed

+56
-3
lines changed

openapi/generated_openapi/zz_generated.openapi.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openapi/openapi.json

Lines changed: 2 additions & 1 deletion
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

Lines changed: 26 additions & 0 deletions
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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,22 @@ 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
59-
Plugins []string `json:"plugins,omitempty"`
62+
Plugins []PluginName `json:"plugins,omitempty"`
6063
// ingress allows to configure the alternative ingress for the console.
6164
// This field is intended for clusters without ingress capability,
6265
// where access to routes is not possible.
6366
// +optional
6467
Ingress Ingress `json:"ingress"`
6568
}
6669

70+
// +kubebuilder:validation:MaxLength=128
71+
// +kubebuilder:validation:Pattern=^[a-zA-Z0-9-]+$
72+
type PluginName string
73+
6774
// ConsoleConfigRoute holds information on external route access to console.
6875
// DEPRECATED
6976
type ConsoleConfigRoute struct {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,8 +779,15 @@ spec:
779779
plugins:
780780
description: plugins defines a list of enabled console plugin names.
781781
items:
782+
maxLength: 128
783+
pattern: ^[a-zA-Z0-9-]+$
782784
type: string
785+
maxItems: 64
783786
type: array
787+
x-kubernetes-list-type: atomic
788+
x-kubernetes-validations:
789+
- message: each plugin name must be unique
790+
rule: self.all(x, self.exists_one(y, x == y))
784791
providers:
785792
description: providers contains configuration for using specific service
786793
providers.

operator/v1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,15 @@ spec:
780780
plugins:
781781
description: plugins defines a list of enabled console plugin names.
782782
items:
783+
maxLength: 128
784+
pattern: ^[a-zA-Z0-9-]+$
783785
type: string
786+
maxItems: 64
784787
type: array
788+
x-kubernetes-list-type: atomic
789+
x-kubernetes-validations:
790+
- message: each plugin name must be unique
791+
rule: self.all(x, self.exists_one(y, x == y))
785792
providers:
786793
description: providers contains configuration for using specific service
787794
providers.

0 commit comments

Comments
 (0)