Skip to content

Commit b701172

Browse files
committed
[runx] Use standard github token env name
1 parent 1045205 commit b701172

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+
// TODO: 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)