-
Notifications
You must be signed in to change notification settings - Fork 0
/
sshagent.go
41 lines (31 loc) · 969 Bytes
/
sshagent.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package sshagent
import (
"github.com/gostevedore/stevedore/internal/core/domain/credentials"
"github.com/gostevedore/stevedore/internal/core/ports/repository"
)
type SSHAgentAuthMethod struct {
GitSSHUser string `json:"git_ssh_user"`
}
// NewSSHAgentAuthMethod creates a new SSHAgentAuthMethod from the given credential
func NewSSHAgentAuthMethod() *SSHAgentAuthMethod {
return &SSHAgentAuthMethod{}
}
// AuthMethodConstructor return a SSHAgentAuthMethod
func (auth *SSHAgentAuthMethod) AuthMethodConstructor(credential *credentials.Credential) (repository.AuthMethodReader, error) {
if credential == nil {
return nil, nil
}
if !credential.AllowUseSSHAgent {
return nil, nil
}
if credential.GitSSHUser != "" {
auth = &SSHAgentAuthMethod{
GitSSHUser: credential.GitSSHUser,
}
}
return auth, nil
}
// Name returns the name of the authentication method
func (a *SSHAgentAuthMethod) Name() string {
return credentials.SSHAgentAuthMethod
}