1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-07-05 00:59:04 +02:00

github enterprise config update

This commit is contained in:
Carlos Alexandro Becker
2017-09-26 18:33:22 -03:00
parent 9ddf723c4e
commit fd0e57ee4e
4 changed files with 25 additions and 19 deletions

View File

@ -7,7 +7,6 @@ import (
"github.com/apex/log"
"github.com/google/go-github/github"
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
"golang.org/x/oauth2"
)
@ -17,24 +16,22 @@ type githubClient struct {
}
// NewGitHub returns a github client implementation
func NewGitHub(ctx *context.Context, repo config.Repo) (Client, error) {
func NewGitHub(ctx *context.Context) (Client, error) {
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: ctx.Token},
)
client := github.NewClient(oauth2.NewClient(ctx, ts))
if repo.APIURL != "" {
url, err := url.Parse(repo.APIURL)
if ctx.Config.GitHubURLs.API != "" {
api, err := url.Parse(ctx.Config.GitHubURLs.API)
if err != nil {
return &githubClient{}, err
}
client.BaseURL = url
}
if repo.UploadsURL != "" {
url, err := url.Parse(repo.UploadsURL)
upload, err := url.Parse(ctx.Config.GitHubURLs.Upload)
if err != nil {
return &githubClient{}, err
}
client.UploadURL = url
client.BaseURL = api
client.UploadURL = upload
}
return &githubClient{client}, nil