Skip to content

Commit

Permalink
feat: Use Rate Limit GH Client
Browse files Browse the repository at this point in the history
* Leveraging existing patterns/code used for the normal terraform-provider-github package which was first implimented in [this PR](integrations/terraform-provider-github#145)
* Upgraded GH client to v54 for compatibility
  • Loading branch information
alex-bourla-form3 committed Sep 5, 2023
1 parent 3b15329 commit 4ffe71d
Show file tree
Hide file tree
Showing 1,112 changed files with 121,633 additions and 139,968 deletions.
22 changes: 13 additions & 9 deletions codeowners/provider.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package codeowners

import (
"context"
"fmt"

"github.com/google/go-github/v42/github"
"github.com/google/go-github/v54/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"golang.org/x/oauth2"
tpg "github.com/integrations/terraform-provider-github/v5/github"
)

// Provider exposes the provider to terraform
Expand Down Expand Up @@ -72,15 +72,19 @@ type providerConfiguration struct {

func providerConfigure(d *schema.ResourceData) (interface{}, error) {

ctx := context.Background()
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: d.Get("github_token").(string)},
)
tc := oauth2.NewClient(ctx, ts)
c := tpg.Config{
Token: d.Get("github_token").(string),
BaseURL: "https://api.github.com/",
}

gc, err := c.NewRESTClient(c.AuthenticatedHTTPClient())
if err != nil {
return nil, fmt.Errorf("failed to create GitHub Client: %v", err)
}

return &providerConfiguration{
commitMessagePrefix: d.Get("commit_message_prefix").(string),
client: github.NewClient(tc),
client: gc,
ghEmail: d.Get("email").(string),
ghUsername: d.Get("username").(string),
gpgKey: d.Get("gpg_secret_key").(string),
Expand Down
2 changes: 1 addition & 1 deletion codeowners/resource_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

githubcommitutils "github.com/form3tech-oss/go-github-utils/pkg/commit"
githubfileutils "github.com/form3tech-oss/go-github-utils/pkg/file"
"github.com/google/go-github/v42/github"
"github.com/google/go-github/v54/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion codeowners/resource_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"testing"

"github.com/google/go-github/v42/github"
"github.com/google/go-github/v54/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/terraform"
)
Expand Down
122 changes: 74 additions & 48 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,77 +3,103 @@ module github.com/form3tech-oss/terraform-provider-codeowners
go 1.17

require (
github.com/form3tech-oss/go-github-utils v0.0.0-20220202160928-550ce279ed0c
github.com/google/go-github/v42 v42.0.0
github.com/stretchr/testify v1.4.0
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
github.com/form3tech-oss/go-github-utils v0.0.0-20230904135919-8fc6a34927e8
github.com/google/go-github/v54 v54.0.0
github.com/integrations/terraform-provider-github/v5 v5.34.0
github.com/stretchr/testify v1.8.4
)

require (
github.com/hashicorp/hcl/v2 v2.0.0 // indirect
github.com/hashicorp/terraform-json v0.4.0 // indirect
github.com/hashicorp/terraform-plugin-test v1.2.0 // indirect
github.com/hashicorp/terraform-svchost v0.0.0-20191011084731-65d371908596 // indirect
cloud.google.com/go/compute v1.20.1 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v0.13.0 // indirect
cloud.google.com/go/storage v1.29.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Masterminds/sprig v2.22.0+incompatible // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 // indirect
github.com/apparentlymart/go-textseg/v12 v12.0.0 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/s2a-go v0.1.4 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/hcl/v2 v2.8.2 // indirect
github.com/hashicorp/terraform-exec v0.13.3 // indirect
github.com/hashicorp/terraform-json v0.10.0 // indirect
github.com/hashicorp/terraform-plugin-test/v2 v2.2.1 // indirect
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
github.com/huandu/xstrings v1.3.2 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/shurcooL/githubv4 v0.0.0-20221126192849-0b5c4c7994eb // indirect
github.com/shurcooL/graphql v0.0.0-20220606043923-3cf50f8a0a29 // indirect
github.com/vmihailenco/msgpack/v4 v4.3.12 // indirect
github.com/vmihailenco/tagparser v0.1.1 // indirect
golang.org/x/oauth2 v0.11.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

require (
cloud.google.com/go v0.45.1 // indirect
cloud.google.com/go v0.110.2 // indirect
github.com/agext/levenshtein v1.2.2 // indirect
github.com/apparentlymart/go-cidr v1.0.1 // indirect
github.com/apparentlymart/go-textseg v1.0.0 // indirect
github.com/apparentlymart/go-cidr v1.1.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/aws/aws-sdk-go v1.25.3 // indirect
github.com/aws/aws-sdk-go v1.44.122 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/golang/protobuf v1.3.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/gax-go/v2 v2.11.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
github.com/hashicorp/go-getter v1.4.0 // indirect
github.com/hashicorp/go-hclog v0.9.2 // indirect
github.com/hashicorp/go-multierror v1.0.0 // indirect
github.com/hashicorp/go-plugin v1.0.1 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.7.0 // indirect
github.com/hashicorp/go-hclog v1.2.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-plugin v1.3.0 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-uuid v1.0.1 // indirect
github.com/hashicorp/go-version v1.2.0 // indirect
github.com/hashicorp/golang-lru v0.5.1 // indirect
github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-config-inspect v0.0.0-20191115094559-17f92b0546e8 // indirect
github.com/hashicorp/terraform-plugin-sdk v1.7.0
github.com/hashicorp/terraform-config-inspect v0.0.0-20191212124732-c6ae6269b9d7 // indirect
github.com/hashicorp/terraform-plugin-sdk v1.17.2
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect
github.com/mattn/go-colorable v0.1.1 // indirect
github.com/mattn/go-isatty v0.0.5 // indirect
github.com/mitchellh/cli v1.0.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mitchellh/cli v1.1.2 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/mitchellh/copystructure v1.0.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.1 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/posener/complete v1.2.1 // indirect
github.com/spf13/afero v1.2.2 // indirect
github.com/ulikunitz/xz v0.5.5 // indirect
github.com/vmihailenco/msgpack v4.0.1+incompatible // indirect
github.com/zclconf/go-cty v1.2.1 // indirect
github.com/zclconf/go-cty-yaml v1.0.1 // indirect
go.opencensus.io v0.22.0 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 // indirect
golang.org/x/text v0.3.3 // indirect
google.golang.org/api v0.9.0 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/spf13/afero v1.4.1 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/zclconf/go-cty v1.8.2 // indirect
github.com/zclconf/go-cty-yaml v1.0.2 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
google.golang.org/api v0.126.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 // indirect
google.golang.org/grpc v1.23.0 // indirect
gopkg.in/yaml.v2 v2.2.2 // indirect
google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc // indirect
google.golang.org/grpc v1.55.0 // indirect
)
Loading

0 comments on commit 4ffe71d

Please sign in to comment.