Skip to content

Commit

Permalink
Add option to skip RateLimitTransport
Browse files Browse the repository at this point in the history
  • Loading branch information
Everton Moreth committed Jun 5, 2019
1 parent e6946cb commit 72fe53e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion github/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Config struct {
Organization string
BaseURL string
Insecure bool
Serial bool
}

type Organization struct {
Expand Down Expand Up @@ -43,7 +44,9 @@ func (c *Config) Client() (interface{}, error) {

tc.Transport = NewEtagTransport(tc.Transport)

tc.Transport = NewRateLimitTransport(tc.Transport)
if c.Insecure {
tc.Transport = NewRateLimitTransport(tc.Transport)
}

tc.Transport = logging.NewTransport("Github", tc.Transport)

Expand Down
13 changes: 13 additions & 0 deletions github/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ func Provider() terraform.ResourceProvider {
Default: false,
Description: descriptions["insecure"],
},
"serial": {
Type: schema.TypeBool,
Optional: true,
Default: true,
Description: descriptions["serial"],
},
},

ResourcesMap: map[string]*schema.Resource{
Expand Down Expand Up @@ -82,6 +88,12 @@ func init() {

"insecure": "Whether server should be accessed " +
"without verifying the TLS certificate.",

"serial": "Whether server should be accessed " +
"serially or concurrently. " +
"Concurrent is faster but requests may reach Github API " +
"rate limit when more than 5000 requests are made " +
"within an hour and can't be retried.",
}
}

Expand All @@ -92,6 +104,7 @@ func providerConfigure(p *schema.Provider) schema.ConfigureFunc {
Organization: d.Get("organization").(string),
BaseURL: d.Get("base_url").(string),
Insecure: d.Get("insecure").(bool),
Serial: d.Get("serial").(bool),
}

meta, err := config.Client()
Expand Down

0 comments on commit 72fe53e

Please sign in to comment.