bake: ensure remote files behind ssh expose agent

The updateContext function may make modifications to the build inputs,
creating either an SSH URL, or an SSH llb.State. In these cases, we need
to ensure that we appropriately expose the client's default agent.

Previously, we would only expose it if the remote context was a git URL,
however, we need to also ensure that if the input was used to override
the context (in the case of ReadRemoteFiles), that we expose the agent
here as well.

Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
Justin Chadwell 2023-04-12 11:00:55 +01:00
parent 672eeed9a6
commit 6c0547e7e6

View File

@ -1105,7 +1105,7 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(sshSpecs) == 0 && buildflags.IsGitSSH(contextPath) { if len(sshSpecs) == 0 && (buildflags.IsGitSSH(bi.ContextPath) || (inp != nil && buildflags.IsGitSSH(inp.URL))) {
sshSpecs = append(sshSpecs, &controllerapi.SSH{ID: "default"}) sshSpecs = append(sshSpecs, &controllerapi.SSH{ID: "default"})
} }
sshAttachment, err := controllerapi.CreateSSH(sshSpecs) sshAttachment, err := controllerapi.CreateSSH(sshSpecs)