Conversation
Co-authored-by: Alexander Hebel <a.hebelsun@gmail.com>
pkg/apis/aws/validation/filter.go
Outdated
| GatewayEndpointRegex = `^\w+(\.\w+)*$` | ||
|
|
||
| validateK8sResourceName = combineValidationFuncs(regex(k8sResourceNameRegex), minLength(1), maxLength(253)) | ||
| validateVpcID = combineValidationFuncs(regex(VpcIDRegex), maxLength(255)) |
There was a problem hiding this comment.
With the current approach, if an empty value is checked by a validator without minLength() it will pass through, because regex returns early without error...
I don't think this is the behaviour we want.
we could add minLength(1) to all or adjust the regex function.
There was a problem hiding this comment.
Also, we should add test cases for these empty values!
pkg/apis/aws/validation/filter.go
Outdated
| return func(name string, fld *field.Path) field.ErrorList { | ||
| var allErrs field.ErrorList | ||
| if utf8.RuneCountInString(name) < min { | ||
| return field.ErrorList{field.Invalid(fld, name, fmt.Sprintf("must not be fewer than %d characters, got %d", min, len(name)))} |
There was a problem hiding this comment.
To prevent confusion, let's use utf8.RuneCountInString() also in the error message.
|
The changes primarily revolve around validating AWS configuration inputs more strictly by introducing various regular expressions. It enhances input validation for a range of AWS resource identifiers and names, including VPC IDs, IAM instance profile names and ARNs, and more. This will improve error handling and user experience by capturing invalid configurations earlier. The accompanying tests ensure these validations work as intended. Walkthrough
Model: gpt-4o | Prompt Tokens: 7124 | Completion Tokens: 170 |
How to categorize this PR?
/area control-plane
/kind enhancement
/platform aws
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #1491
Special notes for your reviewer:
Release note: