MCPcopy
hub / github.com/semaphoreui/semaphore / getAuthMethod

Method getAuthMethod

db_lib/GoGitClient.go:41–78  ·  view source on GitHub ↗
(r GitRepository)

Source from the content-addressed store, hash-verified

39}
40
41func (c GoGitClient) getAuthMethod(r GitRepository) (transport.AuthMethod, error) {
42 switch r.Repository.SSHKey.Type {
43 case db.AccessKeySSH:
44
45 install, err := c.keyInstaller.Install(r.Repository.SSHKey, db.AccessKeyRoleGit, r.Logger)
46 if err != nil {
47 return nil, err
48 }
49
50 defer install.Destroy()
51
52 var sshKeyBuff = r.Repository.SSHKey.SshKey.PrivateKey
53
54 if r.Repository.SSHKey.SshKey.Login == "" {
55 r.Repository.SSHKey.SshKey.Login = "git"
56 }
57
58 publicKey, sshErr := ssh.NewPublicKeys(r.Repository.SSHKey.SshKey.Login, []byte(sshKeyBuff), r.Repository.SSHKey.SshKey.Passphrase)
59
60 if sshErr != nil {
61 return nil, sshErr
62 }
63 publicKey.HostKeyCallback = ssh2.InsecureIgnoreHostKey()
64
65 return publicKey, sshErr
66 case db.AccessKeyLoginPassword:
67 password := &http.BasicAuth{
68 Username: r.Repository.SSHKey.LoginPassword.Login,
69 Password: r.Repository.SSHKey.LoginPassword.Password,
70 }
71
72 return password, nil
73 case db.AccessKeyNone:
74 return nil, nil
75 default:
76 return nil, errors.New("unsupported auth method")
77 }
78}
79
80func openRepository(r GitRepository, targetDir GitRepositoryDirType) (*git.Repository, error) {
81

Callers 5

CloneMethod · 0.95
PullMethod · 0.95
CanBePulledMethod · 0.95
GetRemoteBranchesMethod · 0.95

Calls 2

InstallMethod · 0.65
DestroyMethod · 0.45

Tested by

no test coverage detected