Skip to content

Commit d582954

Browse files
committed
refactor validation and add ratcheting validation
1 parent 40d7615 commit d582954

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

config/v1/tests/infrastructures.config.openshift.io/AAA_ungated.yaml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1985,4 +1985,48 @@ tests:
19851985
platformStatus:
19861986
type: AWS
19871987
aws: {}
1988-
expectedStatusError: "status.platformStatus.aws: Invalid value: \"object\": resourceTags may only be configured during installation"
1988+
expectedStatusError: "status.platformStatus.aws: Invalid value: \"object\": resourceTags may only be configured during installation"
1989+
- name: Ratcheting validation for AWS prefix ResourceTags should not break updates
1990+
initialCRDPatches:
1991+
- op: remove
1992+
path: /spec/versions/0/schema/openAPIV3Schema/properties/status/properties/platformStatus/properties/aws/properties/resourceTags/items/properties/key/x-kubernetes-validations
1993+
initial: |
1994+
apiVersion: config.openshift.io/v1
1995+
kind: Infrastructure
1996+
spec: {}
1997+
status:
1998+
platform: AWS
1999+
platformStatus:
2000+
type: AWS
2001+
aws:
2002+
resourceTags:
2003+
- {key: "aws:invalidKey", value: "value"}
2004+
updated: |
2005+
apiVersion: config.openshift.io/v1
2006+
kind: Infrastructure
2007+
spec: {}
2008+
status:
2009+
platform: AWS
2010+
platformStatus:
2011+
type: AWS
2012+
aws:
2013+
resourceTags:
2014+
- {key: "aws:invalidKey", value: "value"}
2015+
serviceEndpoints:
2016+
- {name: "newendpoint", url: "https://www.awsendpoint.com"}
2017+
expected: |
2018+
apiVersion: config.openshift.io/v1
2019+
kind: Infrastructure
2020+
spec: {}
2021+
status:
2022+
platform: AWS
2023+
controlPlaneTopology: HighlyAvailable
2024+
cpuPartitioning: None
2025+
infrastructureTopology: HighlyAvailable
2026+
platformStatus:
2027+
type: AWS
2028+
aws:
2029+
resourceTags:
2030+
- {key: "aws:invalidKey", value: "value"}
2031+
serviceEndpoints:
2032+
- {name: "newendpoint", url: "https://www.awsendpoint.com"}

config/v1/types_infrastructure.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ type AWSPlatformSpec struct {
503503
}
504504

505505
// AWSPlatformStatus holds the current status of the Amazon Web Services infrastructure provider.
506-
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.resourceTags) && !has(self.resourceTags) || has(oldSelf.resourceTags) && has(self.resourceTags)",message="resourceTags may only be configured during installation"
506+
// +kubebuilder:validation:XValidation:rule="has(oldSelf.resourceTags) == has(self.resourceTags)",message="resourceTags may only be configured during installation"
507507
type AWSPlatformStatus struct {
508508
// region holds the default AWS region for new AWS resources created by the cluster.
509509
Region string `json:"region"`

0 commit comments

Comments
 (0)