Skip to content

Commit

Permalink
Created example for new FeatureGateAwareMaxItems.
Browse files Browse the repository at this point in the history
  • Loading branch information
vr4manta committed May 7, 2024
1 parent 26c44f1 commit a1c8128
Show file tree
Hide file tree
Showing 12 changed files with 103 additions and 32 deletions.
Expand Up @@ -216,38 +216,6 @@ tests:
- IBMCloud2
port: 443
server: server2.dev.cluster.com
# expected: |
# apiVersion: config.openshift.io/v1
# kind: Infrastructure
# spec:
# platformSpec:
# type: VSphere
# vsphere:
# failureDomains:
# - name: generated-failure-domain
# region: generated-region
# server: server1.dev.cluster.com
# topology:
# computeCluster: /IBMCloud/host/vcs-8e-workload
# datacenter: IBMCloud
# datastore: /IBMCloud/datastore/mdcnc-ds-shared
# networks:
# - ocp-ci-seg-13
# resourcePool: /IBMCloud/host/vcs-8e-workload/Resources
# template: /IBMCloud/vm/ngirard-dev-rqh5s-rhcos-generated-region-generated-zone
# zone: generated-zone
# nodeNetworking:
# external: {}
# internal: {}
# vcenters:
# - datacenters:
# - IBMCloud
# port: 443
# server: server1.dev.cluster.com
# - datacenters:
# - IBMCloud2
# port: 443
# server: server2.dev.cluster.com
expectedError: "Too many: 2: must have at most 1 items"
onUpdate:
- name: Should be able to change External platformName from unknown to something else
Expand Down
8 changes: 8 additions & 0 deletions example/v1/types_stable.go
Expand Up @@ -67,6 +67,14 @@ type StableConfigTypeSpec struct {
// celUnion demonstrates how to validate a discrminated union using CEL
// +optional
CELUnion CELUnion `json:"celUnion,omitempty"`

// evolvingCollection demonstrates how to have a collection where the maximum number of items varies on cluster type.
// For default clusters, this will be "1" but on TechPreview clusters, this value will be "3".
// +openshift:validation:FeatureGateAwareMaxItems:featureGate="",maxItems=1
// +openshift:validation:FeatureGateAwareMaxItems:featureGate=Example,maxItems=3
// +optional
// +listType=atomic
EvolvingCollection []string `json:"evolvingCollection,omitempty"`
}

type EvolvingUnion struct {
Expand Down
Expand Up @@ -71,6 +71,16 @@ spec:
description: coolNewField is a field that is for tech preview only. On
normal clusters this shouldn't be present
type: string
evolvingCollection:
description: evolvingCollection demonstrates how to have a collection
where the maximum number of items varies on cluster type. For default
clusters, this will be "1" but on TechPreview clusters, this value
will be "3".
items:
type: string
maxItems: 3
type: array
x-kubernetes-list-type: atomic
evolvingUnion:
description: evolvingUnion demonstrates how to phase in new values
into discriminated union
Expand Down
Expand Up @@ -67,6 +67,16 @@ spec:
- message: optionalMember is forbidden when type is not OptionalMember
rule: 'has(self.type) && self.type == ''OptionalMember'' ? true
: !has(self.optionalMember)'
evolvingCollection:
description: evolvingCollection demonstrates how to have a collection
where the maximum number of items varies on cluster type. For default
clusters, this will be "1" but on TechPreview clusters, this value
will be "3".
items:
type: string
maxItems: 1
type: array
x-kubernetes-list-type: atomic
evolvingUnion:
description: evolvingUnion demonstrates how to phase in new values
into discriminated union
Expand Down
Expand Up @@ -71,6 +71,16 @@ spec:
description: coolNewField is a field that is for tech preview only. On
normal clusters this shouldn't be present
type: string
evolvingCollection:
description: evolvingCollection demonstrates how to have a collection
where the maximum number of items varies on cluster type. For default
clusters, this will be "1" but on TechPreview clusters, this value
will be "3".
items:
type: string
maxItems: 3
type: array
x-kubernetes-list-type: atomic
evolvingUnion:
description: evolvingUnion demonstrates how to phase in new values
into discriminated union
Expand Down
Expand Up @@ -71,6 +71,16 @@ spec:
description: coolNewField is a field that is for tech preview only. On
normal clusters this shouldn't be present
type: string
evolvingCollection:
description: evolvingCollection demonstrates how to have a collection
where the maximum number of items varies on cluster type. For default
clusters, this will be "1" but on TechPreview clusters, this value
will be "3".
items:
type: string
maxItems: 3
type: array
x-kubernetes-list-type: atomic
evolvingUnion:
description: evolvingUnion demonstrates how to phase in new values
into discriminated union
Expand Down
5 changes: 5 additions & 0 deletions example/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -67,6 +67,16 @@ spec:
- message: optionalMember is forbidden when type is not OptionalMember
rule: 'has(self.type) && self.type == ''OptionalMember'' ? true
: !has(self.optionalMember)'
evolvingCollection:
description: evolvingCollection demonstrates how to have a collection
where the maximum number of items varies on cluster type. For default
clusters, this will be "1" but on TechPreview clusters, this value
will be "3".
items:
type: string
maxItems: 1
type: array
x-kubernetes-list-type: atomic
evolvingUnion:
description: evolvingUnion demonstrates how to phase in new values
into discriminated union
Expand Down
Expand Up @@ -71,6 +71,16 @@ spec:
description: coolNewField is a field that is for tech preview only. On
normal clusters this shouldn't be present
type: string
evolvingCollection:
description: evolvingCollection demonstrates how to have a collection
where the maximum number of items varies on cluster type. For default
clusters, this will be "1" but on TechPreview clusters, this value
will be "3".
items:
type: string
maxItems: 3
type: array
x-kubernetes-list-type: atomic
evolvingUnion:
description: evolvingUnion demonstrates how to phase in new values
into discriminated union
Expand Down
1 change: 1 addition & 0 deletions example/v1/zz_generated.swagger_doc_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions openapi/generated_openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions openapi/openapi.json
Expand Up @@ -12904,6 +12904,15 @@
"type": "string",
"default": ""
},
"evolvingCollection": {
"description": "evolvingCollection demonstrates how to have a collection where the maximum number of items varies on cluster type. For default clusters, this will be \"1\" but on TechPreview clusters, this value will be \"3\".",
"type": "array",
"items": {
"type": "string",
"default": ""
},
"x-kubernetes-list-type": "atomic"
},
"evolvingUnion": {
"description": "evolvingUnion demonstrates how to phase in new values into discriminated union",
"default": {},
Expand Down

0 comments on commit a1c8128

Please sign in to comment.