@@ -338,8 +338,13 @@ func providerConfigure(p *schema.Provider) schema.ConfigureFunc {
338338 token = appToken
339339 }
340340
341+ isGithubDotCom , err := regexp .MatchString ("^" + regexp .QuoteMeta ("https://api.github.com" ), baseURL )
342+ if err != nil {
343+ return nil , err
344+ }
345+
341346 if token == "" {
342- ghAuthToken , err := tokenFromGhCli (baseURL )
347+ ghAuthToken , err := tokenFromGhCli (baseURL , isGithubDotCom )
343348 if err != nil {
344349 return nil , fmt .Errorf ("gh auth token: %w" , err )
345350 }
@@ -359,11 +364,7 @@ func providerConfigure(p *schema.Provider) schema.ConfigureFunc {
359364 log .Printf ("[DEBUG] Setting read_delay_ms to %d" , readDelay )
360365
361366 parallelRequests := d .Get ("parallel_requests" ).(bool )
362- isGithubDotCom , err := regexp .MatchString ("^" + regexp .QuoteMeta ("https://api.github.com" ), baseURL )
363367
364- if err != nil {
365- return nil , err
366- }
367368 if parallelRequests && isGithubDotCom {
368369 return nil , fmt .Errorf ("parallel_requests cannot be true when connecting to public github" )
369370 }
@@ -391,13 +392,13 @@ func providerConfigure(p *schema.Provider) schema.ConfigureFunc {
391392}
392393
393394// See https://github.com/integrations/terraform-provider-github/issues/1822
394- func tokenFromGhCli (baseURL string ) (string , error ) {
395+ func tokenFromGhCli (baseURL string , isGithubDotCom bool ) (string , error ) {
395396 ghCliPath := os .Getenv ("GH_PATH" )
396397 if ghCliPath == "" {
397398 ghCliPath = "gh"
398399 }
399400 hostname := ""
400- if baseURL == "" {
401+ if isGithubDotCom {
401402 hostname = "github.com"
402403 } else {
403404 parsedURL , err := url .Parse (baseURL )
0 commit comments