Skip to content

Commit 86c1c3a

Browse files
authored
[runx] Use standard github token env name (#2635)
## Summary ## How was it tested? ## Community Contribution License All community contributions in this pull request are licensed to the project maintainers under the terms of the [Apache 2 License](https://www.apache.org/licenses/LICENSE-2.0). By creating this pull request, I represent that I have the right to license the contributions to the project maintainers under the Apache 2 License as stated in the [Community Contribution License](https://github.com/jetify-com/opensource/blob/main/CONTRIBUTING.md#community-contribution-license).
1 parent 1045205 commit 86c1c3a

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

internal/devpkg/pkgtype/runx.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import (
1212
const (
1313
RunXScheme = "runx"
1414
RunXPrefix = RunXScheme + ":"
15-
githubAPITokenVarName = "DEVBOX_GITHUB_API_TOKEN"
15+
githubAPITokenVarName = "GITHUB_TOKEN"
16+
// Keep for backwards compatibility
17+
oldGithubAPITokenVarName = "DEVBOX_GITHUB_API_TOKEN"
1618
)
1719

1820
var cachedRegistry *registry.Registry
@@ -23,17 +25,25 @@ func IsRunX(s string) bool {
2325

2426
func RunXClient() *runx.RunX {
2527
return &runx.RunX{
26-
GithubAPIToken: os.Getenv(githubAPITokenVarName),
28+
GithubAPIToken: getGithubToken(),
2729
}
2830
}
2931

3032
func RunXRegistry(ctx context.Context) (*registry.Registry, error) {
3133
if cachedRegistry == nil {
3234
var err error
33-
cachedRegistry, err = registry.NewLocalRegistry(ctx, os.Getenv(githubAPITokenVarName))
35+
cachedRegistry, err = registry.NewLocalRegistry(ctx, getGithubToken())
3436
if err != nil {
3537
return nil, err
3638
}
3739
}
3840
return cachedRegistry, nil
3941
}
42+
43+
func getGithubToken() string {
44+
token := os.Getenv(githubAPITokenVarName)
45+
if token == "" {
46+
token = os.Getenv(oldGithubAPITokenVarName)
47+
}
48+
return token
49+
}

0 commit comments

Comments
 (0)