Skip to content
Permalink
Browse files
fix: broken --ssh-key option
Fixes #1948.
Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
  • Loading branch information
distorhead committed Mar 14, 2022
1 parent 073d527 commit c38925991b3b78dfadf3ca11b837abc5bcf15ecd
Showing with 14 additions and 6 deletions.
  1. +1 −1 pkg/git_repo/remote.go
  2. +13 −5 pkg/ssh_agent/ssh_agent.go
@@ -191,7 +191,7 @@ func (repo *Remote) Clone(ctx context.Context) (bool, error) {
RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
})
if err != nil {
return err
return fmt.Errorf("unable to clone repo: %s", err)
}

if err := repo.updateLastAccessAt(ctx, tmpPath); err != nil {
@@ -23,6 +23,11 @@ var (
tmpSockPath string
)

func setupProcessSSHAgent(sshAuthSock string) error {
SSHAuthSock = sshAuthSock
return os.Setenv("SSH_AUTH_SOCK", SSHAuthSock)
}

func Init(ctx context.Context, keys []string) error {
for _, key := range keys {
if keyExists, err := util.FileExists(key); !keyExists {
@@ -35,10 +40,11 @@ func Init(ctx context.Context, keys []string) error {
if len(keys) > 0 {
agentSock, err := runSSHAgentWithKeys(ctx, keys)
if err != nil {
return err
return fmt.Errorf("unable to run ssh agent with specified keys: %s", err)
}
if err := setupProcessSSHAgent(agentSock); err != nil {
return fmt.Errorf("unable to init ssh auth socket to %q: %s", agentSock, err)
}
SSHAuthSock = agentSock

return nil
}

@@ -80,9 +86,11 @@ func Init(ctx context.Context, keys []string) error {
if len(validKeys) > 0 {
agentSock, err := runSSHAgentWithKeys(ctx, validKeys)
if err != nil {
return err
return fmt.Errorf("unable to run ssh agent with specified keys: %s", err)
}
if err := setupProcessSSHAgent(agentSock); err != nil {
return fmt.Errorf("unable to init ssh auth socket to %q: %s", agentSock, err)
}
SSHAuthSock = agentSock
}
}

0 comments on commit c389259

Please sign in to comment.