ability to get netrc from remote

This commit is contained in:
Brad Rydzewski
2015-04-28 14:39:48 -07:00
parent 6006699109
commit 67a4e302c7
3 changed files with 24 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"strings"
"github.com/drone/drone/common"
@@ -149,6 +150,20 @@ func (g *GitHub) Script(u *common.User, r *common.Repo, b *common.Build) ([]byte
return GetFile(client, r.Owner, r.Name, ".drone.yml", sha)
}
// Netrc returns a .netrc file that can be used to clone
// private repositories from a remote system.
func (g *GitHub) Netrc(u *common.User, r *common.Repo) (*common.Netrc, error) {
url_, err := url.Parse(g.URL)
if err != nil {
return nil, err
}
netrc := &common.Netrc{}
netrc.Login = u.Token
netrc.Password = "x-oauth-basic"
netrc.Machine = url_.Host
return netrc, nil
}
// Activate activates a repository by creating the post-commit hook and
// adding the SSH deploy key, if applicable.
func (g *GitHub) Activate(u *common.User, r *common.Repo, k *common.Keypair, link string) error {