From 3bb56f0eb16ac619a4832b1a0190af0dd549173d Mon Sep 17 00:00:00 2001 From: Brent Barbachem Date: Tue, 12 Nov 2024 13:27:07 -0500 Subject: [PATCH] OCPBUGS-44199: Allow spaces in the aws tags ** White space should be allowed in aws tags. --- pkg/types/aws/validation/platform.go | 2 +- pkg/types/aws/validation/platform_test.go | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pkg/types/aws/validation/platform.go b/pkg/types/aws/validation/platform.go index e90513db724..5cdc76751c3 100644 --- a/pkg/types/aws/validation/platform.go +++ b/pkg/types/aws/validation/platform.go @@ -14,7 +14,7 @@ import ( ) // tagRegex is used to check that the keys and values of a tag contain only valid characters. -var tagRegex = regexp.MustCompile(`^[0-9A-Za-z_.:/=+-@]*$`) +var tagRegex = regexp.MustCompile(`^[0-9A-Za-z_.:/=+-@\p{Z}]*$`) // kubernetesNamespaceRegex is used to check that a tag key is not in the kubernetes.io namespace. var kubernetesNamespaceRegex = regexp.MustCompile(`^([^/]*\.)?kubernetes.io/`) diff --git a/pkg/types/aws/validation/platform_test.go b/pkg/types/aws/validation/platform_test.go index 41de264bf9d..8c7f0dc2ae1 100644 --- a/pkg/types/aws/validation/platform_test.go +++ b/pkg/types/aws/validation/platform_test.go @@ -160,6 +160,26 @@ func TestValidatePlatform(t *testing.T) { }, expected: `^\Qtest-path.userTags[kubernetes.io/cluster/test-cluster]: Invalid value: "shared": Keys with prefix 'kubernetes.io/cluster/' are not allowed for user defined tags\E$`, }, + { + name: "invalid userTags, value with invalid characters", + platform: &aws.Platform{ + Region: "us-east-1", + UserTags: map[string]string{ + "usage-user": "cloud-team-rebase-bot[bot]", + }, + }, + expected: `^\Qtest-path.userTags[usage-user]: Invalid value: "cloud-team-rebase-bot[bot]": value contains invalid characters`, + }, + { + name: "valid userTags, value with spaces", + platform: &aws.Platform{ + Region: "us-east-1", + UserTags: map[string]string{ + "test-key": "this test has spaces", + }, + PropagateUserTag: true, + }, + }, { name: "valid userTags", platform: &aws.Platform{