Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rate limit #2345

Merged
merged 6 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 9 additions & 1 deletion github/resource_github_repository_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package github

import (
"context"
"errors"
"log"
"net/http"
"net/url"
"strings"

Expand Down Expand Up @@ -298,7 +300,13 @@ func resourceGithubRepositoryFileRead(d *schema.ResourceData, meta interface{})
opts.Ref = branch.(string)
}

fc, _, _, _ := client.Repositories.GetContents(ctx, owner, repo, file, opts)
fc, _, _, err := client.Repositories.GetContents(ctx, owner, repo, file, opts)
if err != nil {
var errorResponse *github.ErrorResponse
if errors.As(err, &errorResponse) && errorResponse.Response.StatusCode == http.StatusTooManyRequests {
return err
}
}
if fc == nil {
log.Printf("[INFO] Removing repository path %s/%s/%s from state because it no longer exists in GitHub",
owner, repo, file)
Expand Down
23 changes: 15 additions & 8 deletions github/resource_github_repository_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ func TestAccGithubRepositoryFile(t *testing.T) {
config := fmt.Sprintf(`

resource "github_repository" "test" {
name = "tf-acc-test-%s"
auto_init = true
name = "tf-acc-test-%s"
auto_init = true
vulnerability_alerts = true
}

resource "github_repository_file" "test" {
Expand Down Expand Up @@ -92,8 +93,9 @@ func TestAccGithubRepositoryFile(t *testing.T) {

config := fmt.Sprintf(`
resource "github_repository" "test" {
name = "tf-acc-test-%s"
auto_init = true
name = "tf-acc-test-%s"
auto_init = true
vulnerability_alerts = true
}

resource "github_repository_file" "test" {
Expand All @@ -102,6 +104,9 @@ func TestAccGithubRepositoryFile(t *testing.T) {
file = "README.md"
content = "overwritten"
overwrite_on_create = false
commit_message = "Managed by Terraform"
commit_author = "Terraform User"
commit_email = "terraform@example.com"
}

`, randomID)
Expand Down Expand Up @@ -167,8 +172,9 @@ func TestAccGithubRepositoryFile(t *testing.T) {
config := fmt.Sprintf(`

resource "github_repository" "test" {
name = "tf-acc-test-%s"
auto_init = true
name = "tf-acc-test-%s"
auto_init = true
vulnerability_alerts = true
}

resource "github_branch" "test" {
Expand Down Expand Up @@ -251,8 +257,9 @@ func TestAccGithubRepositoryFile(t *testing.T) {

config := fmt.Sprintf(`
resource "github_repository" "test" {
name = "tf-acc-test-%s"
auto_init = true
name = "tf-acc-test-%s"
auto_init = true
vulnerability_alerts = true
}

resource "github_repository_file" "test" {
Expand Down
Loading