-
Notifications
You must be signed in to change notification settings - Fork 160
Fix func build/deploy validation: Add early validation for conflicting --image and --registry flags #3066
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: main
Are you sure you want to change the base?
Conversation
…between image and registry with different specified resgistry Signed-off-by: RayyanSeliya <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: RayyanSeliya The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @RayyanSeliya. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3066 +/- ##
===========================================
- Coverage 56.94% 40.60% -16.34%
===========================================
Files 133 116 -17
Lines 17094 16582 -512
===========================================
- Hits 9734 6733 -3001
- Misses 6451 9034 +2583
+ Partials 909 815 -94
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I think i am missing some edge cases @gauron99 @lkingland please point out if any the test are still failing :( |
im gonna take a look tomorrow |
Sure no worries !! Good night ! |
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.
perhaps we could simply check that -registry and --image are not given together at all? Image takes precedence now which is correct. But we want to avoid having the need to remove FUNC_REGISTRY
or your registry in config file when trying to once specify --image
for a different registry.
In other words --image
should just take precedence and work even when FUNC_REGISTRY
is specified BUT --image
and --registry
could just return an error saying "just choose one or the other" for simplicity?
Otherwise you would need to check both registries, determine what parts image contains and prepend (which I dont think works currently? check my other comment) and that would require a bit more work and consideration.
@lkingland WDYT?
// Skip validation if image has digest (@sha256:...) - digests are immutable overrides | ||
if !strings.Contains(c.Image, "@sha256:") { | ||
// Only validate if image has explicit registry (contains "/" or ":") | ||
// Simple names like "myimage" are compatible - registry will be prepended |
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.
are they really prepended?
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.
❯ func build --image mine --registry quay.io/dfridric
Building function image
Still building
🙌 Function built: mine
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Changes
/kind enhancement
Fixes #3065
Solution:
Implement a 2-layer error system:
ErrConflictingImageAndRegistry
from validation inpkg/functions/errors.go
cmd/build.go
andcmd/deploy.go
and wrap with user-friendly guidanceImplementation Details:
buildConfig.Validate()
anddeployConfig.Validate()
methodsstrings.HasPrefix()
to check if image starts with registry (allows subnamespaces)Release Note