Refactor GitProvider to take in auth token
This commit is contained in:
@@ -13,22 +13,23 @@ import (
|
||||
)
|
||||
|
||||
type GitHubProvider struct {
|
||||
protocol string
|
||||
baseUrl string
|
||||
protocol string
|
||||
baseUrl string
|
||||
authToken string
|
||||
}
|
||||
|
||||
var _ GitProvider = (*GitHubProvider)(nil)
|
||||
|
||||
func (p *GitHubProvider) FetchAndDeployBranch(owner, repo, branch, authToken, destPath string) (*DeployResult, error) {
|
||||
func (p *GitHubProvider) FetchAndDeployBranch(owner, repo, branch, destPath string) (*DeployResult, error) {
|
||||
baseUrl := strings.TrimSuffix(p.baseUrl, "/")
|
||||
apiUrl := fmt.Sprintf("%s://api.%s/", p.protocol, baseUrl)
|
||||
|
||||
result, err := fetchBranchHead(apiUrl, owner, repo, branch, authToken)
|
||||
result, err := fetchBranchHead(apiUrl, owner, repo, branch, p.authToken)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("fetching branch head: %w", err)
|
||||
}
|
||||
|
||||
if err = downloadAndExtract(owner, repo, branch, authToken, destPath); err != nil {
|
||||
if err = downloadAndExtract(owner, repo, branch, p.authToken, destPath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user