(r GitRepository)
| 39 | } |
| 40 | |
| 41 | func (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 | |
| 80 | func openRepository(r GitRepository, targetDir GitRepositoryDirType) (*git.Repository, error) { |
| 81 |
no test coverage detected