Skip to content

Commit c389259

Browse files
committed
fix: broken --ssh-key option
Fixes #1948. Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
1 parent 073d527 commit c389259

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

pkg/git_repo/remote.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func (repo *Remote) Clone(ctx context.Context) (bool, error) {
191191
RecurseSubmodules: git.DefaultSubmoduleRecursionDepth,
192192
})
193193
if err != nil {
194-
return err
194+
return fmt.Errorf("unable to clone repo: %s", err)
195195
}
196196

197197
if err := repo.updateLastAccessAt(ctx, tmpPath); err != nil {

pkg/ssh_agent/ssh_agent.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ var (
2323
tmpSockPath string
2424
)
2525

26+
func setupProcessSSHAgent(sshAuthSock string) error {
27+
SSHAuthSock = sshAuthSock
28+
return os.Setenv("SSH_AUTH_SOCK", SSHAuthSock)
29+
}
30+
2631
func Init(ctx context.Context, keys []string) error {
2732
for _, key := range keys {
2833
if keyExists, err := util.FileExists(key); !keyExists {
@@ -35,10 +40,11 @@ func Init(ctx context.Context, keys []string) error {
3540
if len(keys) > 0 {
3641
agentSock, err := runSSHAgentWithKeys(ctx, keys)
3742
if err != nil {
38-
return err
43+
return fmt.Errorf("unable to run ssh agent with specified keys: %s", err)
44+
}
45+
if err := setupProcessSSHAgent(agentSock); err != nil {
46+
return fmt.Errorf("unable to init ssh auth socket to %q: %s", agentSock, err)
3947
}
40-
SSHAuthSock = agentSock
41-
4248
return nil
4349
}
4450

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

0 commit comments

Comments
 (0)