monitor: resolve paths arguments in client#1581
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? |
| // 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.
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.
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.
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.
Thank you for the following-up! LGTM.
Signed-off-by: Kohei Tokunaga <[email protected]>
Signed-off-by: Justin Chadwell <[email protected]>
Following up for #1296 (comment)
Quoted from @jedevc 's comment (#1296 (comment)):
This commit allows using relative paths on
buildx buildarguments by fixing the controller client to resolve paths on the client side.