Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions internal/devpkg/pkgtype/runx.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import (
const (
RunXScheme = "runx"
RunXPrefix = RunXScheme + ":"
githubAPITokenVarName = "DEVBOX_GITHUB_API_TOKEN"
githubAPITokenVarName = "GITHUB_TOKEN"
// TODO: Keep for backwards compatibility
oldGithubAPITokenVarName = "DEVBOX_GITHUB_API_TOKEN"
)

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

func RunXClient() *runx.RunX {
return &runx.RunX{
GithubAPIToken: os.Getenv(githubAPITokenVarName),
GithubAPIToken: getGithubToken(),
}
}

func RunXRegistry(ctx context.Context) (*registry.Registry, error) {
if cachedRegistry == nil {
var err error
cachedRegistry, err = registry.NewLocalRegistry(ctx, os.Getenv(githubAPITokenVarName))
cachedRegistry, err = registry.NewLocalRegistry(ctx, getGithubToken())
if err != nil {
return nil, err
}
}
return cachedRegistry, nil
}

func getGithubToken() string {
token := os.Getenv(githubAPITokenVarName)
if token == "" {
token = os.Getenv(oldGithubAPITokenVarName)
}
return token
}
Loading