Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfloyd authored Sep 27, 2023
2 parents 4d671f6 + c917477 commit 91f7e26
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/immediate-response.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
run: echo "NUMBER=${{ github.event.issue.number || github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"

- name: Respond to issue or PR
uses: peter-evans/create-or-update-comment@1f6c51492b7d8e91122ece56e2eb7ed38df14079
uses: peter-evans/create-or-update-comment@46da6c0d98504aed6fc429519a258b951f23f474
with:
issue-number: ${{ steps.extract.outputs.NUMBER }}
body: >
Expand Down
15 changes: 8 additions & 7 deletions github/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,13 @@ func providerConfigure(p *schema.Provider) schema.ConfigureFunc {
token = appToken
}

isGithubDotCom, err := regexp.MatchString("^"+regexp.QuoteMeta("https://api.github.com"), baseURL)
if err != nil {
return nil, err
}

if token == "" {
ghAuthToken, err := tokenFromGhCli(baseURL)
ghAuthToken, err := tokenFromGhCli(baseURL, isGithubDotCom)
if err != nil {
return nil, fmt.Errorf("gh auth token: %w", err)
}
Expand All @@ -359,11 +364,7 @@ func providerConfigure(p *schema.Provider) schema.ConfigureFunc {
log.Printf("[DEBUG] Setting read_delay_ms to %d", readDelay)

parallelRequests := d.Get("parallel_requests").(bool)
isGithubDotCom, err := regexp.MatchString("^"+regexp.QuoteMeta("https://api.github.com"), baseURL)

if err != nil {
return nil, err
}
if parallelRequests && isGithubDotCom {
return nil, fmt.Errorf("parallel_requests cannot be true when connecting to public github")
}
Expand Down Expand Up @@ -391,13 +392,13 @@ func providerConfigure(p *schema.Provider) schema.ConfigureFunc {
}

// See https://github.com/integrations/terraform-provider-github/issues/1822
func tokenFromGhCli(baseURL string) (string, error) {
func tokenFromGhCli(baseURL string, isGithubDotCom bool) (string, error) {
ghCliPath := os.Getenv("GH_PATH")
if ghCliPath == "" {
ghCliPath = "gh"
}
hostname := ""
if baseURL == "" {
if isGithubDotCom {
hostname = "github.com"
} else {
parsedURL, err := url.Parse(baseURL)
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/branch.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The following arguments are supported:

* `repository` - (Required) The GitHub repository name.

* `branch` - (Required) The repository branch to create.
* `branch` - (Required) The repository branch to retrieve.

## Attribute Reference

Expand Down

0 comments on commit 91f7e26

Please sign in to comment.