Skip to content

Commit 17498eb

Browse files
Merge pull request #2239 from patrickdillon/418-aws-spaces
OCPBUGS-53221: Allow spaces in AWS resource tags
2 parents d6c84c5 + c35e732 commit 17498eb

File tree

39 files changed

+822
-146
lines changed

39 files changed

+822
-146
lines changed

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

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
22
name: "Infrastructure"
33
crdName: infrastructures.config.openshift.io
4+
featureGates:
5+
- -AWSClusterHostedDNS
46
tests:
57
onCreate:
68
- name: Should be able to create a minimal Infrastructure
@@ -1365,3 +1367,163 @@ tests:
13651367
- name: BadService
13661368
url: https://bad-service.com
13671369
expectedStatusError: "platformStatus.ibmcloud.serviceEndpoints[1].name: Unsupported value: \"BadService\": supported values: \"CIS\", \"COS\", \"COSConfig\", \"DNSServices\", \"GlobalCatalog\", \"GlobalSearch\", \"GlobalTagging\", \"HyperProtect\", \"IAM\", \"KeyProtect\", \"ResourceController\", \"ResourceManager\", \"VPC\""
1370+
- name: Should be able to create an aws resourcetag with spaces
1371+
initial: |
1372+
apiVersion: config.openshift.io/v1
1373+
kind: Infrastructure
1374+
spec:
1375+
platformSpec:
1376+
aws: {}
1377+
type: AWS
1378+
status:
1379+
controlPlaneTopology: HighlyAvailable
1380+
cpuPartitioning: None
1381+
infrastructureTopology: HighlyAvailable
1382+
platform: AWS
1383+
platformStatus:
1384+
aws:
1385+
region: us-east-1
1386+
resourceTags:
1387+
- key: key with space
1388+
value: value with space
1389+
type: AWS
1390+
updated: |
1391+
apiVersion: config.openshift.io/v1
1392+
kind: Infrastructure
1393+
spec:
1394+
platformSpec:
1395+
type: AWS
1396+
aws: {}
1397+
status:
1398+
controlPlaneTopology: HighlyAvailable
1399+
cpuPartitioning: None
1400+
infrastructureTopology: HighlyAvailable
1401+
platform: AWS
1402+
platformStatus:
1403+
aws:
1404+
region: us-east-1
1405+
resourceTags:
1406+
- key: key with space
1407+
value: value with space
1408+
type: AWS
1409+
expected: |
1410+
apiVersion: config.openshift.io/v1
1411+
kind: Infrastructure
1412+
spec:
1413+
platformSpec:
1414+
type: AWS
1415+
aws: {}
1416+
status:
1417+
controlPlaneTopology: HighlyAvailable
1418+
cpuPartitioning: None
1419+
infrastructureTopology: HighlyAvailable
1420+
platform: AWS
1421+
platformStatus:
1422+
aws:
1423+
region: us-east-1
1424+
resourceTags:
1425+
- key: key with space
1426+
value: value with space
1427+
type: AWS
1428+
- name: Should be able to create an aws resourcetag with characters '_', '.', '/', '=', '+', '-', ':', '@'
1429+
initial: |
1430+
apiVersion: config.openshift.io/v1
1431+
kind: Infrastructure
1432+
spec:
1433+
platformSpec:
1434+
aws: {}
1435+
type: AWS
1436+
updated: |
1437+
apiVersion: config.openshift.io/v1
1438+
kind: Infrastructure
1439+
spec:
1440+
platformSpec:
1441+
type: AWS
1442+
aws: {}
1443+
status:
1444+
controlPlaneTopology: HighlyAvailable
1445+
cpuPartitioning: None
1446+
infrastructureTopology: HighlyAvailable
1447+
platform: AWS
1448+
platformStatus:
1449+
aws:
1450+
region: us-east-1
1451+
resourceTags:
1452+
- key: key:_./=+-@
1453+
value: value:_./=+-@
1454+
type: AWS
1455+
expected: |
1456+
apiVersion: config.openshift.io/v1
1457+
kind: Infrastructure
1458+
spec:
1459+
platformSpec:
1460+
type: AWS
1461+
aws: {}
1462+
status:
1463+
controlPlaneTopology: HighlyAvailable
1464+
cpuPartitioning: None
1465+
infrastructureTopology: HighlyAvailable
1466+
platform: AWS
1467+
platformStatus:
1468+
aws:
1469+
region: us-east-1
1470+
resourceTags:
1471+
- key: key:_./=+-@
1472+
value: value:_./=+-@
1473+
type: AWS
1474+
- name: Should not be able to create an aws resourcetag with character * in key
1475+
initial: |
1476+
apiVersion: config.openshift.io/v1
1477+
kind: Infrastructure
1478+
spec:
1479+
platformSpec:
1480+
aws: {}
1481+
type: AWS
1482+
updated: |
1483+
apiVersion: config.openshift.io/v1
1484+
kind: Infrastructure
1485+
spec:
1486+
platformSpec:
1487+
type: AWS
1488+
aws: {}
1489+
status:
1490+
controlPlaneTopology: HighlyAvailable
1491+
cpuPartitioning: None
1492+
infrastructureTopology: HighlyAvailable
1493+
platform: AWS
1494+
platformStatus:
1495+
aws:
1496+
region: us-east-1
1497+
resourceTags:
1498+
- key: key:_./=+-@*
1499+
value: value
1500+
type: AWS
1501+
expectedStatusError: "invalid AWS resource tag key. The string can contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', '@'"
1502+
- name: Should not be able to create an aws resourcetag with character * in value
1503+
initial: |
1504+
apiVersion: config.openshift.io/v1
1505+
kind: Infrastructure
1506+
spec:
1507+
platformSpec:
1508+
aws: {}
1509+
type: AWS
1510+
updated: |
1511+
apiVersion: config.openshift.io/v1
1512+
kind: Infrastructure
1513+
spec:
1514+
platformSpec:
1515+
type: AWS
1516+
aws: {}
1517+
status:
1518+
controlPlaneTopology: HighlyAvailable
1519+
cpuPartitioning: None
1520+
infrastructureTopology: HighlyAvailable
1521+
platform: AWS
1522+
platformStatus:
1523+
aws:
1524+
region: us-east-1
1525+
resourceTags:
1526+
- key: key
1527+
value: value*
1528+
type: AWS
1529+
expectedStatusError: "invalid AWS resource tag value. The string can contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', '@'"

config/v1/types_infrastructure.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,20 +525,24 @@ type AWSPlatformStatus struct {
525525

526526
// AWSResourceTag is a tag to apply to AWS resources created for the cluster.
527527
type AWSResourceTag struct {
528-
// key is the key of the tag
528+
// key sets the key of the AWS resource tag key-value pair. Key is required when defining an AWS resource tag.
529+
// Key should consist of between 1 and 128 characters, and may
530+
// contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
529531
// +kubebuilder:validation:Required
530532
// +kubebuilder:validation:MinLength=1
531533
// +kubebuilder:validation:MaxLength=128
532-
// +kubebuilder:validation:Pattern=`^[0-9A-Za-z_.:/=+-@]+$`
534+
// +kubebuilder:validation:XValidation:rule=`self.matches('^[0-9A-Za-z_.:/=+-@ ]+$')`,message="invalid AWS resource tag key. The string can contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', '@'"
533535
// +required
534536
Key string `json:"key"`
535-
// value is the value of the tag.
537+
// value sets the value of the AWS resource tag key-value pair. Value is required when defining an AWS resource tag.
538+
// Value should consist of between 1 and 256 characters, and may
539+
// contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
536540
// Some AWS service do not support empty values. Since tags are added to resources in many services, the
537541
// length of the tag value must meet the requirements of all services.
538542
// +kubebuilder:validation:Required
539543
// +kubebuilder:validation:MinLength=1
540544
// +kubebuilder:validation:MaxLength=256
541-
// +kubebuilder:validation:Pattern=`^[0-9A-Za-z_.:/=+-@]+$`
545+
// +kubebuilder:validation:XValidation:rule=`self.matches('^[0-9A-Za-z_.:/=+-@ ]+$')`,message="invalid AWS resource tag value. The string can contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', '@'"
542546
// +required
543547
Value string `json:"value"`
544548
}

config/v1/zz_generated.crd-manifests/0000_10_config-operator_01_infrastructures-CustomNoUpgrade.crd.yaml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,20 +1213,35 @@ spec:
12131213
created for the cluster.
12141214
properties:
12151215
key:
1216-
description: key is the key of the tag
1216+
description: |-
1217+
key sets the key of the AWS resource tag key-value pair. Key is required when defining an AWS resource tag.
1218+
Key should consist of between 1 and 128 characters, and may
1219+
contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
12171220
maxLength: 128
12181221
minLength: 1
1219-
pattern: ^[0-9A-Za-z_.:/=+-@]+$
12201222
type: string
1223+
x-kubernetes-validations:
1224+
- message: invalid AWS resource tag key. The string
1225+
can contain only the set of alphanumeric characters,
1226+
space (' '), '_', '.', '/', '=', '+', '-', ':',
1227+
'@'
1228+
rule: self.matches('^[0-9A-Za-z_.:/=+-@ ]+$')
12211229
value:
12221230
description: |-
1223-
value is the value of the tag.
1231+
value sets the value of the AWS resource tag key-value pair. Value is required when defining an AWS resource tag.
1232+
Value should consist of between 1 and 256 characters, and may
1233+
contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
12241234
Some AWS service do not support empty values. Since tags are added to resources in many services, the
12251235
length of the tag value must meet the requirements of all services.
12261236
maxLength: 256
12271237
minLength: 1
1228-
pattern: ^[0-9A-Za-z_.:/=+-@]+$
12291238
type: string
1239+
x-kubernetes-validations:
1240+
- message: invalid AWS resource tag value. The string
1241+
can contain only the set of alphanumeric characters,
1242+
space (' '), '_', '.', '/', '=', '+', '-', ':',
1243+
'@'
1244+
rule: self.matches('^[0-9A-Za-z_.:/=+-@ ]+$')
12301245
required:
12311246
- key
12321247
- value

config/v1/zz_generated.crd-manifests/0000_10_config-operator_01_infrastructures-Default.crd.yaml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,20 +1105,35 @@ spec:
11051105
created for the cluster.
11061106
properties:
11071107
key:
1108-
description: key is the key of the tag
1108+
description: |-
1109+
key sets the key of the AWS resource tag key-value pair. Key is required when defining an AWS resource tag.
1110+
Key should consist of between 1 and 128 characters, and may
1111+
contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
11091112
maxLength: 128
11101113
minLength: 1
1111-
pattern: ^[0-9A-Za-z_.:/=+-@]+$
11121114
type: string
1115+
x-kubernetes-validations:
1116+
- message: invalid AWS resource tag key. The string
1117+
can contain only the set of alphanumeric characters,
1118+
space (' '), '_', '.', '/', '=', '+', '-', ':',
1119+
'@'
1120+
rule: self.matches('^[0-9A-Za-z_.:/=+-@ ]+$')
11131121
value:
11141122
description: |-
1115-
value is the value of the tag.
1123+
value sets the value of the AWS resource tag key-value pair. Value is required when defining an AWS resource tag.
1124+
Value should consist of between 1 and 256 characters, and may
1125+
contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
11161126
Some AWS service do not support empty values. Since tags are added to resources in many services, the
11171127
length of the tag value must meet the requirements of all services.
11181128
maxLength: 256
11191129
minLength: 1
1120-
pattern: ^[0-9A-Za-z_.:/=+-@]+$
11211130
type: string
1131+
x-kubernetes-validations:
1132+
- message: invalid AWS resource tag value. The string
1133+
can contain only the set of alphanumeric characters,
1134+
space (' '), '_', '.', '/', '=', '+', '-', ':',
1135+
'@'
1136+
rule: self.matches('^[0-9A-Za-z_.:/=+-@ ]+$')
11221137
required:
11231138
- key
11241139
- value

config/v1/zz_generated.crd-manifests/0000_10_config-operator_01_infrastructures-DevPreviewNoUpgrade.crd.yaml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,20 +1213,35 @@ spec:
12131213
created for the cluster.
12141214
properties:
12151215
key:
1216-
description: key is the key of the tag
1216+
description: |-
1217+
key sets the key of the AWS resource tag key-value pair. Key is required when defining an AWS resource tag.
1218+
Key should consist of between 1 and 128 characters, and may
1219+
contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
12171220
maxLength: 128
12181221
minLength: 1
1219-
pattern: ^[0-9A-Za-z_.:/=+-@]+$
12201222
type: string
1223+
x-kubernetes-validations:
1224+
- message: invalid AWS resource tag key. The string
1225+
can contain only the set of alphanumeric characters,
1226+
space (' '), '_', '.', '/', '=', '+', '-', ':',
1227+
'@'
1228+
rule: self.matches('^[0-9A-Za-z_.:/=+-@ ]+$')
12211229
value:
12221230
description: |-
1223-
value is the value of the tag.
1231+
value sets the value of the AWS resource tag key-value pair. Value is required when defining an AWS resource tag.
1232+
Value should consist of between 1 and 256 characters, and may
1233+
contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
12241234
Some AWS service do not support empty values. Since tags are added to resources in many services, the
12251235
length of the tag value must meet the requirements of all services.
12261236
maxLength: 256
12271237
minLength: 1
1228-
pattern: ^[0-9A-Za-z_.:/=+-@]+$
12291238
type: string
1239+
x-kubernetes-validations:
1240+
- message: invalid AWS resource tag value. The string
1241+
can contain only the set of alphanumeric characters,
1242+
space (' '), '_', '.', '/', '=', '+', '-', ':',
1243+
'@'
1244+
rule: self.matches('^[0-9A-Za-z_.:/=+-@ ]+$')
12301245
required:
12311246
- key
12321247
- value

config/v1/zz_generated.crd-manifests/0000_10_config-operator_01_infrastructures-TechPreviewNoUpgrade.crd.yaml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,20 +1213,35 @@ spec:
12131213
created for the cluster.
12141214
properties:
12151215
key:
1216-
description: key is the key of the tag
1216+
description: |-
1217+
key sets the key of the AWS resource tag key-value pair. Key is required when defining an AWS resource tag.
1218+
Key should consist of between 1 and 128 characters, and may
1219+
contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
12171220
maxLength: 128
12181221
minLength: 1
1219-
pattern: ^[0-9A-Za-z_.:/=+-@]+$
12201222
type: string
1223+
x-kubernetes-validations:
1224+
- message: invalid AWS resource tag key. The string
1225+
can contain only the set of alphanumeric characters,
1226+
space (' '), '_', '.', '/', '=', '+', '-', ':',
1227+
'@'
1228+
rule: self.matches('^[0-9A-Za-z_.:/=+-@ ]+$')
12211229
value:
12221230
description: |-
1223-
value is the value of the tag.
1231+
value sets the value of the AWS resource tag key-value pair. Value is required when defining an AWS resource tag.
1232+
Value should consist of between 1 and 256 characters, and may
1233+
contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
12241234
Some AWS service do not support empty values. Since tags are added to resources in many services, the
12251235
length of the tag value must meet the requirements of all services.
12261236
maxLength: 256
12271237
minLength: 1
1228-
pattern: ^[0-9A-Za-z_.:/=+-@]+$
12291238
type: string
1239+
x-kubernetes-validations:
1240+
- message: invalid AWS resource tag value. The string
1241+
can contain only the set of alphanumeric characters,
1242+
space (' '), '_', '.', '/', '=', '+', '-', ':',
1243+
'@'
1244+
rule: self.matches('^[0-9A-Za-z_.:/=+-@ ]+$')
12301245
required:
12311246
- key
12321247
- value

0 commit comments

Comments
 (0)