From c211c17de8b83cc41798b27c150aa5050d0ad2a3 Mon Sep 17 00:00:00 2001 From: Alex Couture-Beil Date: Tue, 30 Mar 2021 14:16:09 -0700 Subject: [PATCH] use default socket when no --ssh option given Signed-off-by: Alex Couture-Beil --- commands/build.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/commands/build.go b/commands/build.go index d1d66308..8dcdc6a0 100644 --- a/commands/build.go +++ b/commands/build.go @@ -2,6 +2,7 @@ package commands import ( "context" + "fmt" "os" "path/filepath" "strings" @@ -124,7 +125,15 @@ func runBuild(dockerCli command.Cli, in buildOptions) error { } opts.Session = append(opts.Session, secrets) - ssh, err := build.ParseSSHSpecs(in.ssh) + sshSpecs := in.ssh + if len(sshSpecs) == 0 { + defaultSock := os.Getenv("SSH_AUTH_SOCK") + if defaultSock != "" { + sshSpecs = []string{fmt.Sprintf("default=%s", defaultSock)} + } + } + + ssh, err := build.ParseSSHSpecs(sshSpecs) if err != nil { return err }