-
Notifications
You must be signed in to change notification settings - Fork 624
Add utility method for parsing dual-stack and fips URIs #4612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
// 123456789.dkr.ecr.cn-north-1.amazonaws.com.cn/ | ||
// 98765432.dkr.starport.us-west-2.amazonaws.com/ | ||
// 98765432.dkr.starport-fips.us-west-2.amazonaws.com/ | ||
ECRImagePattern = regexp.MustCompile(`(^[a-zA-Z0-9][a-zA-Z0-9-_]*)\.dkr\.((ecr|starport)(` + FIPSKeyword + `)?)\.([\w\-_]+)\.([\w\.\-]+).*`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's check with team but i think starport
is for Gamma so we might not want to expose it here. We will continue getting endpoint overrides for Gamma so it might not be necessary to check it there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
foundFips := (matchedPattern || matchedDualstackPattern) && strings.Contains(uri, FIPSKeyword) | ||
|
||
logger.Info(fmt.Sprintf("URI: %s, Matched Pattern: %t, Matched Dualstack Pattern: %t, IsFIPS: %t", uri, matchedPattern, matchedDualstackPattern, foundFips)) | ||
return matchedPattern, matchedDualstackPattern, foundFips |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering what are the benefits of having three return outputs
vs (isDualStackPattern, isFipsPattern)
I might be wrong but image URI validation is done somewhere elses already?
Summary
Add a utility method to ecs-agent
utils
package to allow parsing a URI (string) and check if it matches ipv4, dual-stack regex patterns and if it is a FIPS endpoint.Implementation details
Using 2 separate patterns for regex (ipv4/dual-stack) check if the supplied URI (string) matches either pattern. If it matches either pattern also check if the URI is a FIPS endpoint
Testing
make test
and local debuggingNew tests cover the changes: yes
Description for the changelog
Add utility method for parsing dual-stack and fips URIs
Additional Information
Does this PR include breaking model changes? If so, Have you added transformation functions?
N/A
Does this PR include the addition of new environment variables in the README?
N/A
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.