-
Notifications
You must be signed in to change notification settings - Fork 174
Closed
Description
Current behavior:
When running func deploy or func build with both --image and --registry flags that specify different registries, the command proceeds to build instead of validating the conflict:
rayyan@rayyan-seliya:/mnt/c/Users/RAYYAN/Desktop/func/myfunction$ func deploy --image ghcr.io/user/func:latest --registry different-registry.com/user
Building function image
^CError: failed to fetch builder image 'ghcr.io/knative/builder-jammy-tiny:latest': context canceledThis forces users to:
- Wait through the entire build process before realizing the conflict
- Manually cancel (Ctrl+C) to stop the misleading build
- Guess what went wrong from a generic "failed to fetch builder image" error
- Not understand that the issue is with conflicting registry specifications
Proposed improvement:
Provide immediate validation and clear guidance when image and registry flags conflict:
Error: conflicting image and registry options
You cannot use both --image and --registry together when they specify different registries.
These are two different ways to specify where to push your function image.
Choose ONE of these approaches:
1. Use --image to specify the complete image name:
func deploy --image <full-image-name>
2. Use --registry and let the system create the image name automatically:
func deploy --registry <registry>
For more options, run 'func deploy --help'For func build:
Error: conflicting image and registry options
You cannot use both --image and --registry together when they specify different registries.
These are two different ways to specify where to push your function image.
Choose ONE of these approaches:
1. Use --image to specify the complete image name:
func build --image <full-image-name>
2. Use --registry and let the system create the image name automatically:
func build --registry <registry>
For more options, run 'func build --help'Solution:
Implement a 2-layer error system:
- Layer 1 (Technical): Return
ErrConflictingImageAndRegistryfrom validation inpkg/functions/errors.go - Layer 2 (CLI): Catch the error in
cmd/build.goandcmd/deploy.goand provide user-friendly guidance
Expected Workflow:
The validation should occur before any build attempts:
- Parse command flags
- Validate flag combinations for conflicts
- Return clear error if conflicts detected
- Only proceed to build if validation passes
Compatibility Notes:
The validation should allow compatible combinations:
- ✅
--registry example.com/alice --image example.com/alice/subnamespace/myfunc(subnamespace) - ✅
--registry example.com/alice --image example.com/alice/func:latest(exact match) - ❌
--registry example.com/alice --image different.com/user/func(different registry)
User Impact:
- Current: Confusing build failure → time wasted waiting → need to investigate → unclear error message
- Improved: Immediate validation → clear error explanation → actionable guidance → better developer experience
Metadata
Metadata
Assignees
Labels
No labels