|
49 | 49 | _cachedCNISupportedInstances *string |
50 | 50 | // This regex is stricter than the actual S3 rules |
51 | 51 | _strictS3BucketRegex = regexp.MustCompile(`^([a-z0-9])+(-[a-z0-9]+)*$`) |
| 52 | + _invalidTagPrefixes = []string{"kubernetes.io/", "k8s.io/", "eksctl.", "alpha.eksctl.", "beta.eksctl.", "aws:", "Aws:", "aWs:", "awS:", "aWS:", "AwS:", "aWS:", "AWS:"} |
52 | 53 | ) |
53 | 54 |
|
54 | 55 | type Config struct { |
@@ -165,16 +166,20 @@ var UserValidation = &cr.StructValidation{ |
165 | 166 | AllowEmpty: true, |
166 | 167 | ConvertNullToEmpty: true, |
167 | 168 | KeyStringValidator: &cr.StringValidation{ |
168 | | - MinLength: 1, |
169 | | - MaxLength: 127, |
170 | | - InvalidPrefixes: []string{"aws:", "Aws:", "aWs:", "awS:", "aWS:", "AwS:", "aWS:", "AWS:"}, |
171 | | - AWSTag: true, |
| 169 | + MinLength: 1, |
| 170 | + MaxLength: 127, |
| 171 | + DisallowLeadingWhitespace: true, |
| 172 | + DisallowTrailingWhitespace: true, |
| 173 | + InvalidPrefixes: _invalidTagPrefixes, |
| 174 | + AWSTag: true, |
172 | 175 | }, |
173 | 176 | ValueStringValidator: &cr.StringValidation{ |
174 | | - MinLength: 1, |
175 | | - MaxLength: 255, |
176 | | - InvalidPrefixes: []string{"aws:", "Aws:", "aWs:", "awS:", "aWS:", "AwS:", "aWS:", "AWS:"}, |
177 | | - AWSTag: true, |
| 177 | + MinLength: 1, |
| 178 | + MaxLength: 255, |
| 179 | + DisallowLeadingWhitespace: true, |
| 180 | + DisallowTrailingWhitespace: true, |
| 181 | + InvalidPrefixes: _invalidTagPrefixes, |
| 182 | + AWSTag: true, |
178 | 183 | }, |
179 | 184 | }, |
180 | 185 | }, |
@@ -547,6 +552,7 @@ func (cc *Config) SQSNamePrefix() string { |
547 | 552 | return SQSNamePrefix(cc.ClusterName) |
548 | 553 | } |
549 | 554 |
|
| 555 | +// this validates the user-provided cluster config |
550 | 556 | func (cc *Config) Validate(awsClient *aws.Client) error { |
551 | 557 | fmt.Print("verifying your configuration ...\n\n") |
552 | 558 |
|
@@ -620,8 +626,10 @@ func (cc *Config) Validate(awsClient *aws.Client) error { |
620 | 626 | } |
621 | 627 | } |
622 | 628 |
|
623 | | - if cc.Tags[ClusterNameTag] != "" && cc.Tags[ClusterNameTag] != cc.ClusterName { |
624 | | - return ErrorCantOverrideDefaultTag() |
| 629 | + for tagName := range cc.Tags { |
| 630 | + if strings.HasPrefix(tagName, "cortex.dev/") { |
| 631 | + return errors.Wrap(cr.ErrorCantHavePrefix(tagName, "cortex.dev/"), TagsKey) |
| 632 | + } |
625 | 633 | } |
626 | 634 | cc.Tags[ClusterNameTag] = cc.ClusterName |
627 | 635 |
|
|
0 commit comments