fix(internal/releaser): add helper method to lookup for provider accesToken in environment variabels

This commit is contained in:
Felix Wiedmann
2019-06-17 22:30:17 +02:00
parent 065070657c
commit 8efde63865
2 changed files with 23 additions and 2 deletions

View File

@@ -29,16 +29,22 @@ type Client struct {
// New initialize a new GitHubRelease
func New(c *config.GitHubProvider) (*Client, error) {
var err error
if c.AccessToken, err = util.GetAccessToken(GITHUB); err != nil {
return &Client{}, err
}
ctx := context.Background()
httpClient := util.CreateBearerHTTPClient(ctx, c.AccessToken)
var client *github.Client
var err error
baseURL := "https://github.com"
if c.CustomURL == "" {
client = github.NewClient(httpClient)
} else {
client, err = github.NewEnterpriseClient(c.CustomURL, c.CustomURL+"/api/v3/", httpClient)
if client, err = github.NewEnterpriseClient(c.CustomURL, c.CustomURL+"/api/v3/", httpClient); err != nil {
return &Client{}, err
}
baseURL = c.CustomURL
}
return &Client{