Skip to content

Commit

Permalink
fix: broken --ssh-key option
Browse files Browse the repository at this point in the history
Fixes #1948.
Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
  • Loading branch information
distorhead committed Mar 14, 2022
1 parent 073d527 commit c389259
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/git_repo/remote.go
Expand Up @@ -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 {
Expand Down
18 changes: 13 additions & 5 deletions pkg/ssh_agent/ssh_agent.go
Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down Expand Up @@ -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
}
}

Expand Down

0 comments on commit c389259

Please sign in to comment.