Skip to content

Commit 799932e

Browse files
authored
fix github api url (#794)
## What previously, when an account `csdpSettings` would contain apiUrl of `https://api.github.com`, the token validation check would call `https://api.github.com/api/v3`. i fixed the githubProvider code to check for "github.com" in the hostname, and if it exists - to not add any `/api/v3` path to the base url at all. ## Why i guess `https://api.github.com/api/v3` use to work, but recently github changed their side, and now it returns 404. ## Notes <!-- Add any additional notes here -->
1 parent b538c14 commit 799932e

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v0.2.10
1+
VERSION=v0.2.11
22

33
OUT_DIR=dist
44
YEAR?=$(shell date +"%Y")

docs/releases/release_notes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cf version
1515

1616
```bash
1717
# download and extract the binary
18-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.2.8/cf-linux-amd64.tar.gz | tar zx
18+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.2.11/cf-linux-amd64.tar.gz | tar zx
1919

2020
# move the binary to your $PATH
2121
mv ./cf-linux-amd64 /usr/local/bin/cf
@@ -28,7 +28,7 @@ cf version
2828

2929
```bash
3030
# download and extract the binary
31-
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.2.8/cf-darwin-amd64.tar.gz | tar zx
31+
curl -L --output - https://github.com/codefresh-io/cli-v2/releases/download/v0.2.11/cf-darwin-amd64.tar.gz | tar zx
3232

3333
# move the binary to your $PATH
3434
mv ./cf-darwin-amd64 /usr/local/bin/cf

internal/git/provider_github.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func NewGithubProvider(baseURL string, client *http.Client) (Provider, error) {
4949
return nil, err
5050
}
5151

52-
if u.Host == GITHUB_CLOUD_DOMAIN {
52+
if strings.Contains(u.Hostname(), GITHUB_CLOUD_DOMAIN) {
5353
u, _ = url.Parse(GITHUB_CLOUD_API_URL)
5454
} else if u.Path == "" {
5555
u.Path = GITHUB_REST_ENDPOINT
@@ -106,7 +106,8 @@ func (g *github) verifyToken(ctx context.Context, token string, requiredScopes [
106106
reqHeaders := map[string]string{
107107
"Authorization": "token " + token,
108108
}
109-
req, err := httputil.NewRequest(ctx, http.MethodHead, g.apiURL.String(), reqHeaders, nil)
109+
url := g.apiURL.String()
110+
req, err := httputil.NewRequest(ctx, http.MethodHead, url, reqHeaders, nil)
110111
if err != nil {
111112
return err
112113
}

0 commit comments

Comments
 (0)