mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-29 17:05:46 +08:00
include default ssh socket when given an ssh-based git url
Signed-off-by: Alex Couture-Beil <alex@earthly.dev>
This commit is contained in:
parent
98d337af21
commit
eec843a325
@ -534,7 +534,11 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
|
|||||||
}
|
}
|
||||||
bo.Session = append(bo.Session, secrets)
|
bo.Session = append(bo.Session, secrets)
|
||||||
|
|
||||||
ssh, err := build.ParseSSHSpecs(t.SSH)
|
sshSpecs := t.SSH
|
||||||
|
if len(sshSpecs) == 0 && build.IsGitSSH(contextPath) {
|
||||||
|
sshSpecs = []string{"default"}
|
||||||
|
}
|
||||||
|
ssh, err := build.ParseSSHSpecs(sshSpecs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/moby/buildkit/session"
|
"github.com/moby/buildkit/session"
|
||||||
"github.com/moby/buildkit/session/sshforward/sshprovider"
|
"github.com/moby/buildkit/session/sshforward/sshprovider"
|
||||||
|
"github.com/moby/buildkit/util/gitutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ParseSSHSpecs(sl []string) (session.Attachable, error) {
|
func ParseSSHSpecs(sl []string) (session.Attachable, error) {
|
||||||
@ -29,3 +30,9 @@ func parseSSH(value string) (*sshprovider.AgentConfig, error) {
|
|||||||
}
|
}
|
||||||
return &cfg, nil
|
return &cfg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsGitSSH returns true if the given repo URL is accessed over ssh
|
||||||
|
func IsGitSSH(url string) bool {
|
||||||
|
_, gitProtocol := gitutil.ParseProtocol(url)
|
||||||
|
return gitProtocol == gitutil.SSHProtocol
|
||||||
|
}
|
||||||
|
@ -124,7 +124,11 @@ func runBuild(dockerCli command.Cli, in buildOptions) error {
|
|||||||
}
|
}
|
||||||
opts.Session = append(opts.Session, secrets)
|
opts.Session = append(opts.Session, secrets)
|
||||||
|
|
||||||
ssh, err := build.ParseSSHSpecs(in.ssh)
|
sshSpecs := in.ssh
|
||||||
|
if len(sshSpecs) == 0 && build.IsGitSSH(in.contextPath) {
|
||||||
|
sshSpecs = []string{"default"}
|
||||||
|
}
|
||||||
|
ssh, err := build.ParseSSHSpecs(sshSpecs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user