-
Notifications
You must be signed in to change notification settings - Fork 299
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
feat(image_spec): validate container registry names #2748
Conversation
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Kevin Su <[email protected]>
flytekit/image_spec/image_spec.py
Outdated
def validate_container_registry_name(name: str) -> bool: | ||
"""Validate Docker container registry name.""" | ||
# Define the regular expression for the registry name | ||
registry_pattern = r"^(localhost:\d{1,5}|([a-z0-9._-]+)(:[0-9]{1,5})?)(/[a-zA-Z0-9._-]+)*$" |
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.
Should the dot be escaped, i.e. .
-> \.
? Also minor nits:
registry_pattern = r"^(localhost:\d{1,5}|([a-z0-9._-]+)(:[0-9]{1,5})?)(/[a-zA-Z0-9._-]+)*$" | |
registry_pattern = r"^(localhost:\d{1,5}|([a-z\d\._-]+)(:\d{1,5})?)(/[\w\.-]+)*$" |
Signed-off-by: Kevin Su <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2748 +/- ##
===========================================
- Coverage 90.87% 74.90% -15.98%
===========================================
Files 74 194 +120
Lines 3331 19765 +16434
Branches 0 4121 +4121
===========================================
+ Hits 3027 14804 +11777
- Misses 304 4221 +3917
- Partials 0 740 +740 ☔ View full report in Codecov by Sentry. |
registry_pattern = r"^(localhost:\d{1,5}|([a-z\d\._-]+)(:\d{1,5})?)(/[\w\.-]+)*$" | ||
|
||
# Use regex to validate the given name | ||
return bool(re.match(registry_pattern, name)) |
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.
It's strange that this is not covered according to codecov. (At some point, I want to be able to trust codecov.)
Tracking issue
closes flyteorg/flyte#5689
Why are the changes needed?
It's better to check if the registry name is valid or not before building and pushing it.
What changes were proposed in this pull request?
validate the name in
__post__init__
How was this patch tested?
unit test
Setup process
Screenshots
Before:
After:
Check all the applicable boxes
Related PRs
NA
Docs link
NA