Skip to content

Commit

Permalink
Use magic path for ssh-agent on darwin.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cedric BAIL committed Aug 26, 2023
1 parent 1065628 commit f350b61
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion internal/command/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@ func (i *localContainerImage) cmd(vol volume.Volume, opts options, cmdArgs []str

// detect ssh-agent socket for private repositories access
if sshAuthSock := os.Getenv("SSH_AUTH_SOCK"); sshAuthSock != "" {
if realSshAuthSock, err := filepath.EvalSymlinks(sshAuthSock); err == nil {
if runtime.GOOS == "darwin" {
// on macOS, the SSH_AUTH_SOCK is not available in the container directly,
// but instead we need to the magic path "/run/host-services/ssh-auth.sock"
args = append(args, "-v", "/run/host-services/ssh-auth.sock:/run/host-services/ssh-auth.sock")
args = append(args, "-e", "SSH_AUTH_SOCK=/run/host-services/ssh-auth.sock")
} else if realSshAuthSock, err := filepath.EvalSymlinks(sshAuthSock); err == nil {
args = append(args, "-v", fmt.Sprintf("%s:/tmp/ssh-agent", realSshAuthSock))
args = append(args, "-e", "SSH_AUTH_SOCK=/tmp/ssh-agent")
}
Expand Down

0 comments on commit f350b61

Please sign in to comment.