Skip to content

Commit e094938

Browse files
author
foyerunix
committed
fix(github): allow to use both token and URL
This commit fix a regresssion introduced in: #21292 Before that, we were able to use both an URL and also an authentication token. Signed-off-by: foyerunix <[email protected]>
1 parent 0484f9f commit e094938

File tree

1 file changed

+6
-10
lines changed
  • applicationset/services/pull_request

1 file changed

+6
-10
lines changed

applicationset/services/pull_request/github.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,13 @@ func NewGithubService(token, url, owner, repo string, labels []string) (PullRequ
2323
if token == "" {
2424
token = os.Getenv("GITHUB_TOKEN")
2525
}
26-
httpClient := &http.Client{}
27-
var client *github.Client
28-
if url == "" {
29-
if token == "" {
30-
client = github.NewClient(httpClient)
31-
} else {
32-
client = github.NewClient(httpClient).WithAuthToken(token)
33-
}
34-
} else {
26+
var client = github.NewClient(&http.Client{})
27+
if token != "" {
28+
client = client.WithAuthToken(token)
29+
}
30+
if url != "" {
3531
var err error
36-
client, err = github.NewClient(httpClient).WithEnterpriseURLs(url, url)
32+
client, err = client.WithEnterpriseURLs(url, url)
3733
if err != nil {
3834
return nil, err
3935
}

0 commit comments

Comments
 (0)