Skip to content

Commit 42edf4f

Browse files
Merge pull request #1383 from dharaneeshvrd/powervs-status-update
Add ResourceGroup field to PowerVSPlatformStatus
2 parents 0755e9d + 925f75a commit 42edf4f

7 files changed

+146
-0
lines changed

config/v1/0000_10_config-operator_01_infrastructure-Default.crd.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,14 @@ spec:
736736
region:
737737
description: region holds the default Power VS region for new Power VS resources created by the cluster.
738738
type: string
739+
resourceGroup:
740+
description: 'resourceGroup is the resource group name for new IBMCloud resources created for a cluster. The resource group specified here will be used by cluster-image-registry-operator to set up a COS Instance in IBMCloud for the cluster registry. More about resource groups can be found here: https://cloud.ibm.com/docs/account?topic=account-rgs. When omitted, the image registry operator won''t be able to configure storage, which results in the image registry cluster operator not being in an available state.'
741+
maxLength: 40
742+
pattern: ^[a-zA-Z0-9-_ ]+$
743+
type: string
744+
x-kubernetes-validations:
745+
- message: resourceGroup is immutable once set
746+
rule: oldSelf == '' || self == oldSelf
739747
serviceEndpoints:
740748
description: serviceEndpoints is a list of custom endpoints which will override the default service endpoints of a Power VS service.
741749
items:
@@ -759,6 +767,9 @@ spec:
759767
description: 'zone holds the default zone for the new Power VS resources created by the cluster. Note: Currently only single-zone OCP clusters are supported'
760768
type: string
761769
type: object
770+
x-kubernetes-validations:
771+
- message: cannot unset resourceGroup once set
772+
rule: '!has(oldSelf.resourceGroup) || has(self.resourceGroup)'
762773
type:
763774
description: "type is the underlying infrastructure provider for the cluster. This value controls whether infrastructure automation such as service load balancers, dynamic volume provisioning, machine creation and deletion, and other integrations are enabled. If None, no infrastructure automation is enabled. Allowed values are \"AWS\", \"Azure\", \"BareMetal\", \"GCP\", \"Libvirt\", \"OpenStack\", \"VSphere\", \"oVirt\", \"EquinixMetal\", \"PowerVS\", \"AlibabaCloud\", \"Nutanix\" and \"None\". Individual components may not support all platforms, and must handle unrecognized platforms as None if they do not support that platform. \n This value will be synced with to the `status.platform` and `status.platformStatus.type`. Currently this value cannot be changed once set."
764775
enum:

config/v1/0000_10_config-operator_01_infrastructure-TechPreviewNoUpgrade.crd.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,14 @@ spec:
807807
region:
808808
description: region holds the default Power VS region for new Power VS resources created by the cluster.
809809
type: string
810+
resourceGroup:
811+
description: 'resourceGroup is the resource group name for new IBMCloud resources created for a cluster. The resource group specified here will be used by cluster-image-registry-operator to set up a COS Instance in IBMCloud for the cluster registry. More about resource groups can be found here: https://cloud.ibm.com/docs/account?topic=account-rgs. When omitted, the image registry operator won''t be able to configure storage, which results in the image registry cluster operator not being in an available state.'
812+
maxLength: 40
813+
pattern: ^[a-zA-Z0-9-_ ]+$
814+
type: string
815+
x-kubernetes-validations:
816+
- message: resourceGroup is immutable once set
817+
rule: oldSelf == '' || self == oldSelf
810818
serviceEndpoints:
811819
description: serviceEndpoints is a list of custom endpoints which will override the default service endpoints of a Power VS service.
812820
items:
@@ -830,6 +838,9 @@ spec:
830838
description: 'zone holds the default zone for the new Power VS resources created by the cluster. Note: Currently only single-zone OCP clusters are supported'
831839
type: string
832840
type: object
841+
x-kubernetes-validations:
842+
- message: cannot unset resourceGroup once set
843+
rule: '!has(oldSelf.resourceGroup) || has(self.resourceGroup)'
833844
type:
834845
description: "type is the underlying infrastructure provider for the cluster. This value controls whether infrastructure automation such as service load balancers, dynamic volume provisioning, machine creation and deletion, and other integrations are enabled. If None, no infrastructure automation is enabled. Allowed values are \"AWS\", \"Azure\", \"BareMetal\", \"GCP\", \"Libvirt\", \"OpenStack\", \"VSphere\", \"oVirt\", \"EquinixMetal\", \"PowerVS\", \"AlibabaCloud\", \"Nutanix\" and \"None\". Individual components may not support all platforms, and must handle unrecognized platforms as None if they do not support that platform. \n This value will be synced with to the `status.platform` and `status.platformStatus.type`. Currently this value cannot be changed once set."
835846
enum:

config/v1/stable.infrastructure.testsuite.yaml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,100 @@ tests:
214214
resourceGroupName: bar
215215
resourceTags:
216216
- {key: "key", value: "value"}
217+
- name: PowerVS platform status's resourceGroup length should not exceed the max length set
218+
initial: |
219+
apiVersion: config.openshift.io/v1
220+
kind: Infrastructure
221+
spec:
222+
platformSpec:
223+
type: PowerVS
224+
status:
225+
platform: PowerVS
226+
platformStatus:
227+
powervs:
228+
resourceGroup: resource-group
229+
updated: |
230+
apiVersion: config.openshift.io/v1
231+
kind: Infrastructure
232+
spec:
233+
platformSpec:
234+
type: PowerVS
235+
status:
236+
platform: PowerVS
237+
platformStatus:
238+
powervs:
239+
resourceGroup: resource-group-should-not-accept-the-string-that-exceeds-max-length-set
240+
expectedStatusError: "status.platformStatus.powervs.resourceGroup: Too long: may not be longer than 40"
241+
- name: PowerVS platform status's resourceGroup should match the regex configured
242+
initial: |
243+
apiVersion: config.openshift.io/v1
244+
kind: Infrastructure
245+
spec:
246+
platformSpec:
247+
type: PowerVS
248+
status:
249+
platform: PowerVS
250+
platformStatus:
251+
powervs:
252+
resourceGroup: resource-group
253+
updated: |
254+
apiVersion: config.openshift.io/v1
255+
kind: Infrastructure
256+
spec:
257+
platformSpec:
258+
type: PowerVS
259+
status:
260+
platform: PowerVS
261+
platformStatus:
262+
powervs:
263+
resourceGroup: re$ource-group
264+
expectedStatusError: "status.platformStatus.powervs.resourceGroup in body should match '^[a-zA-Z0-9-_ ]+$'"
265+
- name: Should not be able to change PowerVS platform status's resourceGroup once it was set
266+
initial: |
267+
apiVersion: config.openshift.io/v1
268+
kind: Infrastructure
269+
spec:
270+
platformSpec:
271+
type: PowerVS
272+
status:
273+
platform: PowerVS
274+
platformStatus:
275+
powervs:
276+
resourceGroup: resource-group
277+
updated: |
278+
apiVersion: config.openshift.io/v1
279+
kind: Infrastructure
280+
spec:
281+
platformSpec:
282+
type: PowerVS
283+
status:
284+
platform: PowerVS
285+
platformStatus:
286+
powervs:
287+
resourceGroup: other-resource-group-name
288+
expectedStatusError: "status.platformStatus.powervs.resourceGroup: Invalid value: \"string\": resourceGroup is immutable once set"
289+
- name: Should not be able to unset PowerVS platform status's resourceGroup once it was set
290+
initial: |
291+
apiVersion: config.openshift.io/v1
292+
kind: Infrastructure
293+
spec:
294+
platformSpec:
295+
type: PowerVS
296+
status:
297+
platform: PowerVS
298+
platformStatus:
299+
powervs:
300+
region: some-region
301+
resourceGroup: resource-group
302+
updated: |
303+
apiVersion: config.openshift.io/v1
304+
kind: Infrastructure
305+
spec:
306+
platformSpec:
307+
type: PowerVS
308+
status:
309+
platform: PowerVS
310+
platformStatus:
311+
powervs:
312+
region: some-region
313+
expectedStatusError: "status.platformStatus.powervs: Invalid value: \"object\": cannot unset resourceGroup once set"

config/v1/types_infrastructure.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,6 +1167,7 @@ type PowerVSPlatformSpec struct {
11671167
}
11681168

11691169
// PowerVSPlatformStatus holds the current status of the IBM Power Systems Virtual Servers infrastrucutre provider.
1170+
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.resourceGroup) || has(self.resourceGroup)",message="cannot unset resourceGroup once set"
11701171
type PowerVSPlatformStatus struct {
11711172
// region holds the default Power VS region for new Power VS resources created by the cluster.
11721173
Region string `json:"region"`
@@ -1175,6 +1176,18 @@ type PowerVSPlatformStatus struct {
11751176
// Note: Currently only single-zone OCP clusters are supported
11761177
Zone string `json:"zone"`
11771178

1179+
// resourceGroup is the resource group name for new IBMCloud resources created for a cluster.
1180+
// The resource group specified here will be used by cluster-image-registry-operator to set up a COS Instance in IBMCloud for the cluster registry.
1181+
// More about resource groups can be found here: https://cloud.ibm.com/docs/account?topic=account-rgs.
1182+
// When omitted, the image registry operator won't be able to configure storage,
1183+
// which results in the image registry cluster operator not being in an available state.
1184+
//
1185+
// +kubebuilder:validation:Pattern=^[a-zA-Z0-9-_ ]+$
1186+
// +kubebuilder:validation:MaxLength=40
1187+
// +kubebuilder:validation:XValidation:rule="oldSelf == '' || self == oldSelf",message="resourceGroup is immutable once set"
1188+
// +optional
1189+
ResourceGroup string `json:"resourceGroup"`
1190+
11781191
// serviceEndpoints is a list of custom endpoints which will override the default
11791192
// service endpoints of a Power VS service.
11801193
// +optional

config/v1/zz_generated.swagger_doc_generated.go

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

openapi/generated_openapi/zz_generated.openapi.go

Lines changed: 8 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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8542,6 +8542,11 @@
85428542
"type": "string",
85438543
"default": ""
85448544
},
8545+
"resourceGroup": {
8546+
"description": "resourceGroup is the resource group name for new IBMCloud resources created for a cluster. The resource group specified here will be used by cluster-image-registry-operator to set up a COS Instance in IBMCloud for the cluster registry. More about resource groups can be found here: https://cloud.ibm.com/docs/account?topic=account-rgs. When omitted, the image registry operator won't be able to configure storage, which results in the image registry cluster operator not being in an available state.",
8547+
"type": "string",
8548+
"default": ""
8549+
},
85458550
"serviceEndpoints": {
85468551
"description": "serviceEndpoints is a list of custom endpoints which will override the default service endpoints of a Power VS service.",
85478552
"type": "array",

0 commit comments

Comments
 (0)