Respect GITHUB_TOKEN in api command
This commit is contained in:
parent
2e93a065b1
commit
13ba0aa56e
1 changed files with 8 additions and 4 deletions
|
|
@ -71,10 +71,14 @@ func init() {
|
|||
cmdFactory := &cmdutil.Factory{
|
||||
IOStreams: iostreams.System(),
|
||||
HttpClient: func() (*http.Client, error) {
|
||||
ctx := context.New()
|
||||
token, err := ctx.AuthToken()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
token := os.Getenv("GITHUB_TOKEN")
|
||||
if len(token) == 0 {
|
||||
ctx := context.New()
|
||||
var err error
|
||||
token, err = ctx.AuthToken()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return httpClient(token), nil
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue