-
Notifications
You must be signed in to change notification settings - Fork 500
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
bake: infer git auth token from remote files to build request #2905
Conversation
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.
This should be only if the context is git based I think. A remote bake definition may not always use the same remote URL as a context.
I see but that could be unreliable if I use a remote bake def that has a target with subdir context like: target "default" {
context = "./subdir"
} But I guess I can just check context does not start with |
|
Yes indeed, let me check this |
1d59cbc
to
119af60
Compare
@tonistiigi Should be good now |
bake/bake.go
Outdated
@@ -1338,7 +1338,23 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) { | |||
} | |||
bo.Platforms = platforms | |||
|
|||
bo.SecretSpecs = t.Secrets.ToPB() | |||
secrets := t.Secrets | |||
if build.IsRemoteURL(bi.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 don't think this is correct. I think if you have a subpath in bake and command invoked directly then the contextpath in here is a subdir but the contextstate has been replaced with something like llb.Git().Copy("subdir")
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.
Ah you right it would not work for this case
Signed-off-by: CrazyMax <[email protected]>
119af60
to
45fc5ed
Compare
if build.IsRemoteURL(t.ContextPath) { | ||
return true | ||
} | ||
if inp != nil && build.IsRemoteURL(inp.URL) && !strings.HasPrefix(t.ContextPath, "cwd://") { |
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.
isn't inp.URL
always URL if it is set?
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.
Yes if a remote bake def is set but if context is set to git context it is not (first cond in isRemoteContext
):
docker buildx bake --set *.context=https://github.com/docker/buildx.git --print
{
"group": {
"default": {
"targets": [
"binaries"
]
}
},
"target": {
"binaries": {
"context": "https://github.com/docker/buildx.git",
"dockerfile": "Dockerfile",
"args": {
"BUILDKIT_CONTEXT_KEEP_GIT_DIR": "1"
},
"target": "binaries",
"platforms": [
"local"
],
"output": [
{
"dest": "./bin/build",
"type": "local"
}
]
}
}
}
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.
Isn't that the build.IsRemoteURL(t.ContextPath) {
, how does that affect inp.URL
?
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.
Isn't that the
build.IsRemoteURL(t.ContextPath) {
,
Yes it is but inp.URL
is only set when remote bake def arg is set:
Line 557 in 026ac23
rfiles, inp, err = bake.ReadRemoteFiles(ctx, nodes, url, rnames, pw) |
It doesn't take into account git urls in context within bake def or override.
When
BUILDX_BAKE_GIT_AUTH_*
env is set to fetch a remote bake definition, we should infer this git auth token to build request if a Git context is detected.