-
Notifications
You must be signed in to change notification settings - Fork 573
monitor: resolve paths arguments in client #1581
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
Conversation
Hm, I'm fairly sure we should look for a better way to go about this 🤔 As is, this looks really tricky to maintain over time, and I think it's best to avoid modifying the user-provided options wherever possible. I think we need to push down the file resolution to the components that actually open the files, though those are scattered in BuildKit's client code as well as in Buildx. For example, in Buildkit, we need to handle it here: buildx/vendor/github.com/moby/buildkit/client/solve.go Lines 193 to 201 in 6506166
To get the information of the right path through - I think we need to add a current working directory field to the For things like the metadata file, and secrets, we need to handle those buildx-side - so we'd need to add the same working directory property to the I think this would work better as a long-term approach? The buildkit-side patches shouldn't be too complex, and should just affect the client, so we wouldn't need new capabilities or anything. @tonistiigi are we missing an easier option here? |
commands/build.go
Outdated
// and replaces them to absolute paths. | ||
func resolvePaths(options *controllerapi.BuildOptions) (_ *controllerapi.BuildOptions, err error) { | ||
if options.ContextPath != "-" { | ||
options.ContextPath, err = absIfLocal(options.ContextPath) |
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.
I'm not sure if we should do os.Stat
here as part of absIfLocal
? I think we should just do filepath.Abs
, and similarly below.
We know at this point it's definitely a path, and if the file doesn't exist, we should let the controller throw the error (which may or may not be a file not found error, we shouldn't assume the implementation at this point).
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.
Thank you for the comment. Yes, we don't need os.Stat here because the options are already strongly typed. Fixed the patch.
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.
I just pushed a commit on top to handle the new oci-layout named context (which can also be a path). Does that seem good to you? If so, I think this is ready-to-go 🎉
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.
Thank you for the following-up! LGTM.
Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
Signed-off-by: Justin Chadwell <me@jedevc.com>
Following up for #1296 (comment)
Quoted from @jedevc 's comment (#1296 (comment)):
This commit allows using relative paths on
buildx build
arguments by fixing the controller client to resolve paths on the client side.