Skip to content

Commit f5b09d1

Browse files
Merge pull request #2124 from patrickdillon/aws-tag-space
OCPBUGS-44199: Allow spaces in AWS tags
2 parents b8a067b + d5168f3 commit f5b09d1

File tree

42 files changed

+879
-158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+879
-158
lines changed

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

+162
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
@@ -1675,3 +1677,163 @@ tests:
16751677
serviceEndpoints:
16761678
- name: DNSServices
16771679
url: https://abc
1680+
- name: Should be able to create an aws resourcetag with spaces
1681+
initial: |
1682+
apiVersion: config.openshift.io/v1
1683+
kind: Infrastructure
1684+
spec:
1685+
platformSpec:
1686+
aws: {}
1687+
type: AWS
1688+
status:
1689+
controlPlaneTopology: HighlyAvailable
1690+
cpuPartitioning: None
1691+
infrastructureTopology: HighlyAvailable
1692+
platform: AWS
1693+
platformStatus:
1694+
aws:
1695+
region: us-east-1
1696+
resourceTags:
1697+
- key: key with space
1698+
value: value with space
1699+
type: AWS
1700+
updated: |
1701+
apiVersion: config.openshift.io/v1
1702+
kind: Infrastructure
1703+
spec:
1704+
platformSpec:
1705+
type: AWS
1706+
aws: {}
1707+
status:
1708+
controlPlaneTopology: HighlyAvailable
1709+
cpuPartitioning: None
1710+
infrastructureTopology: HighlyAvailable
1711+
platform: AWS
1712+
platformStatus:
1713+
aws:
1714+
region: us-east-1
1715+
resourceTags:
1716+
- key: key with space
1717+
value: value with space
1718+
type: AWS
1719+
expected: |
1720+
apiVersion: config.openshift.io/v1
1721+
kind: Infrastructure
1722+
spec:
1723+
platformSpec:
1724+
type: AWS
1725+
aws: {}
1726+
status:
1727+
controlPlaneTopology: HighlyAvailable
1728+
cpuPartitioning: None
1729+
infrastructureTopology: HighlyAvailable
1730+
platform: AWS
1731+
platformStatus:
1732+
aws:
1733+
region: us-east-1
1734+
resourceTags:
1735+
- key: key with space
1736+
value: value with space
1737+
type: AWS
1738+
- name: Should be able to create an aws resourcetag with characters '_', '.', '/', '=', '+', '-', ':', '@'
1739+
initial: |
1740+
apiVersion: config.openshift.io/v1
1741+
kind: Infrastructure
1742+
spec:
1743+
platformSpec:
1744+
aws: {}
1745+
type: AWS
1746+
updated: |
1747+
apiVersion: config.openshift.io/v1
1748+
kind: Infrastructure
1749+
spec:
1750+
platformSpec:
1751+
type: AWS
1752+
aws: {}
1753+
status:
1754+
controlPlaneTopology: HighlyAvailable
1755+
cpuPartitioning: None
1756+
infrastructureTopology: HighlyAvailable
1757+
platform: AWS
1758+
platformStatus:
1759+
aws:
1760+
region: us-east-1
1761+
resourceTags:
1762+
- key: key:_./=+-@
1763+
value: value:_./=+-@
1764+
type: AWS
1765+
expected: |
1766+
apiVersion: config.openshift.io/v1
1767+
kind: Infrastructure
1768+
spec:
1769+
platformSpec:
1770+
type: AWS
1771+
aws: {}
1772+
status:
1773+
controlPlaneTopology: HighlyAvailable
1774+
cpuPartitioning: None
1775+
infrastructureTopology: HighlyAvailable
1776+
platform: AWS
1777+
platformStatus:
1778+
aws:
1779+
region: us-east-1
1780+
resourceTags:
1781+
- key: key:_./=+-@
1782+
value: value:_./=+-@
1783+
type: AWS
1784+
- name: Should not be able to create an aws resourcetag with character * in key
1785+
initial: |
1786+
apiVersion: config.openshift.io/v1
1787+
kind: Infrastructure
1788+
spec:
1789+
platformSpec:
1790+
aws: {}
1791+
type: AWS
1792+
updated: |
1793+
apiVersion: config.openshift.io/v1
1794+
kind: Infrastructure
1795+
spec:
1796+
platformSpec:
1797+
type: AWS
1798+
aws: {}
1799+
status:
1800+
controlPlaneTopology: HighlyAvailable
1801+
cpuPartitioning: None
1802+
infrastructureTopology: HighlyAvailable
1803+
platform: AWS
1804+
platformStatus:
1805+
aws:
1806+
region: us-east-1
1807+
resourceTags:
1808+
- key: key:_./=+-@*
1809+
value: value
1810+
type: AWS
1811+
expectedStatusError: "invalid AWS resource tag key. The string can contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', '@'"
1812+
- name: Should not be able to create an aws resourcetag with character * in value
1813+
initial: |
1814+
apiVersion: config.openshift.io/v1
1815+
kind: Infrastructure
1816+
spec:
1817+
platformSpec:
1818+
aws: {}
1819+
type: AWS
1820+
updated: |
1821+
apiVersion: config.openshift.io/v1
1822+
kind: Infrastructure
1823+
spec:
1824+
platformSpec:
1825+
type: AWS
1826+
aws: {}
1827+
status:
1828+
controlPlaneTopology: HighlyAvailable
1829+
cpuPartitioning: None
1830+
infrastructureTopology: HighlyAvailable
1831+
platform: AWS
1832+
platformStatus:
1833+
aws:
1834+
region: us-east-1
1835+
resourceTags:
1836+
- key: key
1837+
value: value*
1838+
type: AWS
1839+
expectedStatusError: "invalid AWS resource tag value. The string can contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', '@'"

config/v1/types_infrastructure.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -528,18 +528,22 @@ type AWSPlatformStatus struct {
528528

529529
// AWSResourceTag is a tag to apply to AWS resources created for the cluster.
530530
type AWSResourceTag struct {
531-
// key is the key of the tag
531+
// key sets the key of the AWS resource tag key-value pair. Key is required when defining an AWS resource tag.
532+
// Key should consist of between 1 and 128 characters, and may
533+
// contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
532534
// +kubebuilder:validation:MinLength=1
533535
// +kubebuilder:validation:MaxLength=128
534-
// +kubebuilder:validation:Pattern=`^[0-9A-Za-z_.:/=+-@]+$`
536+
// +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 (' '), '_', '.', '/', '=', '+', '-', ':', '@'"
535537
// +required
536538
Key string `json:"key"`
537-
// value is the value of the tag.
539+
// value sets the value of the AWS resource tag key-value pair. Value is required when defining an AWS resource tag.
540+
// Value should consist of between 1 and 256 characters, and may
541+
// contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
538542
// Some AWS service do not support empty values. Since tags are added to resources in many services, the
539543
// length of the tag value must meet the requirements of all services.
540544
// +kubebuilder:validation:MinLength=1
541545
// +kubebuilder:validation:MaxLength=256
542-
// +kubebuilder:validation:Pattern=`^[0-9A-Za-z_.:/=+-@]+$`
546+
// +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 (' '), '_', '.', '/', '=', '+', '-', ':', '@'"
543547
// +required
544548
Value string `json:"value"`
545549
}

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

+19-4
Original file line numberDiff line numberDiff line change
@@ -1305,20 +1305,35 @@ spec:
13051305
created for the cluster.
13061306
properties:
13071307
key:
1308-
description: key is the key of the tag
1308+
description: |-
1309+
key sets the key of the AWS resource tag key-value pair. Key is required when defining an AWS resource tag.
1310+
Key should consist of between 1 and 128 characters, and may
1311+
contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
13091312
maxLength: 128
13101313
minLength: 1
1311-
pattern: ^[0-9A-Za-z_.:/=+-@]+$
13121314
type: string
1315+
x-kubernetes-validations:
1316+
- message: invalid AWS resource tag key. The string
1317+
can contain only the set of alphanumeric characters,
1318+
space (' '), '_', '.', '/', '=', '+', '-', ':',
1319+
'@'
1320+
rule: self.matches('^[0-9A-Za-z_.:/=+-@ ]+$')
13131321
value:
13141322
description: |-
1315-
value is the value of the tag.
1323+
value sets the value of the AWS resource tag key-value pair. Value is required when defining an AWS resource tag.
1324+
Value should consist of between 1 and 256 characters, and may
1325+
contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
13161326
Some AWS service do not support empty values. Since tags are added to resources in many services, the
13171327
length of the tag value must meet the requirements of all services.
13181328
maxLength: 256
13191329
minLength: 1
1320-
pattern: ^[0-9A-Za-z_.:/=+-@]+$
13211330
type: string
1331+
x-kubernetes-validations:
1332+
- message: invalid AWS resource tag value. The string
1333+
can contain only the set of alphanumeric characters,
1334+
space (' '), '_', '.', '/', '=', '+', '-', ':',
1335+
'@'
1336+
rule: self.matches('^[0-9A-Za-z_.:/=+-@ ]+$')
13221337
required:
13231338
- key
13241339
- value

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

+19-4
Original file line numberDiff line numberDiff line change
@@ -1185,20 +1185,35 @@ spec:
11851185
created for the cluster.
11861186
properties:
11871187
key:
1188-
description: key is the key of the tag
1188+
description: |-
1189+
key sets the key of the AWS resource tag key-value pair. Key is required when defining an AWS resource tag.
1190+
Key should consist of between 1 and 128 characters, and may
1191+
contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
11891192
maxLength: 128
11901193
minLength: 1
1191-
pattern: ^[0-9A-Za-z_.:/=+-@]+$
11921194
type: string
1195+
x-kubernetes-validations:
1196+
- message: invalid AWS resource tag key. The string
1197+
can contain only the set of alphanumeric characters,
1198+
space (' '), '_', '.', '/', '=', '+', '-', ':',
1199+
'@'
1200+
rule: self.matches('^[0-9A-Za-z_.:/=+-@ ]+$')
11931201
value:
11941202
description: |-
1195-
value is the value of the tag.
1203+
value sets the value of the AWS resource tag key-value pair. Value is required when defining an AWS resource tag.
1204+
Value should consist of between 1 and 256 characters, and may
1205+
contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
11961206
Some AWS service do not support empty values. Since tags are added to resources in many services, the
11971207
length of the tag value must meet the requirements of all services.
11981208
maxLength: 256
11991209
minLength: 1
1200-
pattern: ^[0-9A-Za-z_.:/=+-@]+$
12011210
type: string
1211+
x-kubernetes-validations:
1212+
- message: invalid AWS resource tag value. The string
1213+
can contain only the set of alphanumeric characters,
1214+
space (' '), '_', '.', '/', '=', '+', '-', ':',
1215+
'@'
1216+
rule: self.matches('^[0-9A-Za-z_.:/=+-@ ]+$')
12021217
required:
12031218
- key
12041219
- value

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

+19-4
Original file line numberDiff line numberDiff line change
@@ -1305,20 +1305,35 @@ spec:
13051305
created for the cluster.
13061306
properties:
13071307
key:
1308-
description: key is the key of the tag
1308+
description: |-
1309+
key sets the key of the AWS resource tag key-value pair. Key is required when defining an AWS resource tag.
1310+
Key should consist of between 1 and 128 characters, and may
1311+
contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
13091312
maxLength: 128
13101313
minLength: 1
1311-
pattern: ^[0-9A-Za-z_.:/=+-@]+$
13121314
type: string
1315+
x-kubernetes-validations:
1316+
- message: invalid AWS resource tag key. The string
1317+
can contain only the set of alphanumeric characters,
1318+
space (' '), '_', '.', '/', '=', '+', '-', ':',
1319+
'@'
1320+
rule: self.matches('^[0-9A-Za-z_.:/=+-@ ]+$')
13131321
value:
13141322
description: |-
1315-
value is the value of the tag.
1323+
value sets the value of the AWS resource tag key-value pair. Value is required when defining an AWS resource tag.
1324+
Value should consist of between 1 and 256 characters, and may
1325+
contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
13161326
Some AWS service do not support empty values. Since tags are added to resources in many services, the
13171327
length of the tag value must meet the requirements of all services.
13181328
maxLength: 256
13191329
minLength: 1
1320-
pattern: ^[0-9A-Za-z_.:/=+-@]+$
13211330
type: string
1331+
x-kubernetes-validations:
1332+
- message: invalid AWS resource tag value. The string
1333+
can contain only the set of alphanumeric characters,
1334+
space (' '), '_', '.', '/', '=', '+', '-', ':',
1335+
'@'
1336+
rule: self.matches('^[0-9A-Za-z_.:/=+-@ ]+$')
13221337
required:
13231338
- key
13241339
- value

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

+19-4
Original file line numberDiff line numberDiff line change
@@ -1305,20 +1305,35 @@ spec:
13051305
created for the cluster.
13061306
properties:
13071307
key:
1308-
description: key is the key of the tag
1308+
description: |-
1309+
key sets the key of the AWS resource tag key-value pair. Key is required when defining an AWS resource tag.
1310+
Key should consist of between 1 and 128 characters, and may
1311+
contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
13091312
maxLength: 128
13101313
minLength: 1
1311-
pattern: ^[0-9A-Za-z_.:/=+-@]+$
13121314
type: string
1315+
x-kubernetes-validations:
1316+
- message: invalid AWS resource tag key. The string
1317+
can contain only the set of alphanumeric characters,
1318+
space (' '), '_', '.', '/', '=', '+', '-', ':',
1319+
'@'
1320+
rule: self.matches('^[0-9A-Za-z_.:/=+-@ ]+$')
13131321
value:
13141322
description: |-
1315-
value is the value of the tag.
1323+
value sets the value of the AWS resource tag key-value pair. Value is required when defining an AWS resource tag.
1324+
Value should consist of between 1 and 256 characters, and may
1325+
contain only the set of alphanumeric characters, space (' '), '_', '.', '/', '=', '+', '-', ':', and '@'.
13161326
Some AWS service do not support empty values. Since tags are added to resources in many services, the
13171327
length of the tag value must meet the requirements of all services.
13181328
maxLength: 256
13191329
minLength: 1
1320-
pattern: ^[0-9A-Za-z_.:/=+-@]+$
13211330
type: string
1331+
x-kubernetes-validations:
1332+
- message: invalid AWS resource tag value. The string
1333+
can contain only the set of alphanumeric characters,
1334+
space (' '), '_', '.', '/', '=', '+', '-', ':',
1335+
'@'
1336+
rule: self.matches('^[0-9A-Za-z_.:/=+-@ ]+$')
13221337
required:
13231338
- key
13241339
- value

0 commit comments

Comments
 (0)