Skip to content

Commit

Permalink
Merge pull request #14 from Flaconi/update-6.2.1
Browse files Browse the repository at this point in the history
Update to 6.2.1 from upstream
snovikov authored Jun 12, 2024
2 parents 66d27bd + 49d1f2e commit 09831f5
Showing 4,521 changed files with 259,246 additions and 479,519 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
34 changes: 34 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes

changelog:
categories:
- title: 💥 Breaking Changes
labels:
- "Type: Breaking change"

- title: 🚀 New Features
labels:
- "Type: Feature"
- "New data source"
- "New resource"

- title: 🐛 Bugfixes
labels:
- "Type: Bug"

- title: 🪦 Deprecations
labels:
- "Deprecation"

- title: 🛠️ Maintenance
labels:
- "Type: Maintenance"
- "dependencies"

- title: 📝 Documentation
labels:
- "Type: Documentation"

- title: 🏷 Other Changes
labels:
- "*"
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@ on:
jobs:
ci:
runs-on: ubuntu-latest
env:
GITHUB_TEST_ORGANIZATION: 'kfcampbell-terraform-provider'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
2 changes: 1 addition & 1 deletion .github/workflows/immediate-response.yml
Original file line number Diff line number Diff line change
@@ -19,7 +19,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@v3
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ steps.extract.outputs.NUMBER }}
body: >
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -21,5 +21,5 @@ linters:

linters-settings:
errcheck:
ignore: github.com/hashicorp/terraform-plugin-sdk/helper/schema:ForceNew|Set,fmt:.*,io:Close
ignore: github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema:ForceNew|Set,fmt:.*,io:Close

20 changes: 14 additions & 6 deletions github/config.go
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import (
"time"

"github.com/google/go-github/v57/github"
"github.com/hashicorp/terraform-plugin-sdk/helper/logging"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
"github.com/shurcooL/githubv4"
"golang.org/x/oauth2"
)
@@ -21,6 +21,9 @@ type Config struct {
Insecure bool
WriteDelay time.Duration
ReadDelay time.Duration
RetryDelay time.Duration
RetryableErrors map[int]bool
MaxRetries int
ParallelRequests bool
}

@@ -33,16 +36,20 @@ type Owner struct {
IsOrganization bool
}

func RateLimitedHTTPClient(client *http.Client, writeDelay time.Duration, readDelay time.Duration, parallelRequests bool) *http.Client {
func RateLimitedHTTPClient(client *http.Client, writeDelay time.Duration, readDelay time.Duration, retryDelay time.Duration, parallelRequests bool, retryableErrors map[int]bool, maxRetries int) *http.Client {

client.Transport = NewEtagTransport(client.Transport)
client.Transport = NewRateLimitTransport(client.Transport, WithWriteDelay(writeDelay), WithReadDelay(readDelay), WithParallelRequests(parallelRequests))
client.Transport = logging.NewTransport("GitHub", client.Transport)
client.Transport = logging.NewSubsystemLoggingHTTPTransport("GitHub", client.Transport)
client.Transport = newPreviewHeaderInjectorTransport(map[string]string{
// TODO: remove when Stone Crop preview is moved to general availability in the GraphQL API
"Accept": "application/vnd.github.stone-crop-preview+json",
}, client.Transport)

if maxRetries > 0 {
client.Transport = NewRetryTransport(client.Transport, WithRetryDelay(retryDelay), WithRetryableErrors(retryableErrors), WithMaxRetries(maxRetries))
}

return client
}

@@ -54,7 +61,7 @@ func (c *Config) AuthenticatedHTTPClient() *http.Client {
)
client := oauth2.NewClient(ctx, ts)

return RateLimitedHTTPClient(client, c.WriteDelay, c.ReadDelay, c.ParallelRequests)
return RateLimitedHTTPClient(client, c.WriteDelay, c.ReadDelay, c.RetryDelay, c.ParallelRequests, c.RetryableErrors, c.MaxRetries)
}

func (c *Config) Anonymous() bool {
@@ -63,7 +70,7 @@ func (c *Config) Anonymous() bool {

func (c *Config) AnonymousHTTPClient() *http.Client {
client := &http.Client{Transport: &http.Transport{}}
return RateLimitedHTTPClient(client, c.WriteDelay, c.ReadDelay, c.ParallelRequests)
return RateLimitedHTTPClient(client, c.WriteDelay, c.ReadDelay, c.RetryDelay, c.ParallelRequests, c.RetryableErrors, c.MaxRetries)
}

func (c *Config) NewGraphQLClient(client *http.Client) (*githubv4.Client, error) {
@@ -130,7 +137,7 @@ func (c *Config) ConfigureOwner(owner *Owner) (*Owner, error) {
}

// Meta returns the meta parameter that is passed into subsequent resources
// https://godoc.org/github.com/hashicorp/terraform-plugin-sdk/helper/schema#ConfigureFunc
// https://godoc.org/github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema#ConfigureFunc
func (c *Config) Meta() (interface{}, error) {

var client *http.Client
@@ -153,6 +160,7 @@ func (c *Config) Meta() (interface{}, error) {
var owner Owner
owner.v4client = v4client
owner.v3client = v3client
owner.StopContext = context.Background()

_, err = c.ConfigureOwner(&owner)
if err != nil {
25 changes: 25 additions & 0 deletions github/config_test.go
Original file line number Diff line number Diff line change
@@ -58,6 +58,31 @@ func TestAccConfigMeta(t *testing.T) {

})

t.Run("returns a v3 REST API client with max retries", func(t *testing.T) {

config := Config{
Token: testToken,
BaseURL: "https://api.github.com/",
RetryableErrors: map[int]bool{
500: true,
502: true,
},
MaxRetries: 3,
}
meta, err := config.Meta()
if err != nil {
t.Fatalf("failed to return meta without error: %s", err.Error())
}

ctx := context.Background()
client := meta.(*Owner).v3client
_, _, err = client.Meta.Get(ctx)
if err != nil {
t.Fatalf("failed to validate returned client without error: %s", err.Error())
}

})

t.Run("returns a v4 GraphQL API client to manage individual resources", func(t *testing.T) {

config := Config{
2 changes: 1 addition & 1 deletion github/data_source_github_actions_environment_secrets.go
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import (

"github.com/google/go-github/v57/github"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceGithubActionsEnvironmentSecrets() *schema.Resource {
4 changes: 2 additions & 2 deletions github/data_source_github_actions_environment_secrets_test.go
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@ import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccGithubActionsEnvironmentSecretsDataSource(t *testing.T) {
2 changes: 1 addition & 1 deletion github/data_source_github_actions_environment_variables.go
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import (

"github.com/google/go-github/v57/github"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceGithubActionsEnvironmentVariables() *schema.Resource {
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@ import (
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccGithubActionsEnvironmentVariablesDataSource(t *testing.T) {
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package github

import (
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceGithubActionsOrganizationOIDCSubjectClaimCustomizationTemplate() *schema.Resource {
@@ -38,7 +38,10 @@ func dataSourceGithubActionsOrganizationOIDCSubjectClaimCustomizationTemplateRea
}

d.SetId(orgName)
d.Set("include_claim_keys", template.IncludeClaimKeys)
err = d.Set("include_claim_keys", template.IncludeClaimKeys)
if err != nil {
return err
}

return nil
}
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package github
import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccGithubActionsOrganizationOIDCSubjectClaimCustomizationTemplateDataSource(t *testing.T) {
12 changes: 9 additions & 3 deletions github/data_source_github_actions_organization_public_key.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package github
import (
"context"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceGithubActionsOrganizationPublicKey() *schema.Resource {
@@ -40,8 +40,14 @@ func dataSourceGithubActionsOrganizationPublicKeyRead(d *schema.ResourceData, me
}

d.SetId(publicKey.GetKeyID())
d.Set("key_id", publicKey.GetKeyID())
d.Set("key", publicKey.GetKey())
err = d.Set("key_id", publicKey.GetKeyID())
if err != nil {
return err
}
err = d.Set("key", publicKey.GetKey())
if err != nil {
return err
}

return nil
}
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package github
import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccGithubActionsOrganizationPublicKeyDataSource(t *testing.T) {
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import (
"fmt"
"log"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceGithubActionsOrganizationRegistrationToken() *schema.Resource {
@@ -36,8 +36,14 @@ func dataSourceGithubActionsOrganizationRegistrationTokenRead(d *schema.Resource
}

d.SetId(owner)
d.Set("token", token.Token)
d.Set("expires_at", token.ExpiresAt.Unix())
err = d.Set("token", token.Token)
if err != nil {
return err
}
err = d.Set("expires_at", token.ExpiresAt.Unix())
if err != nil {
return err
}

return nil
}
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package github
import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccGithubActionsOrganizationRegistrationTokenDataSource(t *testing.T) {
7 changes: 5 additions & 2 deletions github/data_source_github_actions_organization_secrets.go
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import (

"github.com/google/go-github/v57/github"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceGithubActionsOrganizationSecrets() *schema.Resource {
@@ -72,7 +72,10 @@ func dataSourceGithubActionsOrganizationSecretsRead(d *schema.ResourceData, meta
}

d.SetId(owner)
d.Set("secrets", all_secrets)
err := d.Set("secrets", all_secrets)
if err != nil {
return err
}

return nil
}
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@ import (
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccGithubActionsOrganizationSecretsDataSource(t *testing.T) {
7 changes: 5 additions & 2 deletions github/data_source_github_actions_organization_variables.go
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import (

"github.com/google/go-github/v57/github"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceGithubActionsOrganizationVariables() *schema.Resource {
@@ -76,7 +76,10 @@ func dataSourceGithubActionsOrganizationVariablesRead(d *schema.ResourceData, me
}

d.SetId(owner)
d.Set("variables", all_variables)
err := d.Set("variables", all_variables)
if err != nil {
return err
}

return nil
}
Original file line number Diff line number Diff line change
@@ -5,8 +5,8 @@ import (
"strings"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func TestAccGithubActionsOrganizationVariablesDataSource(t *testing.T) {
12 changes: 9 additions & 3 deletions github/data_source_github_actions_public_key.go
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ package github
import (
"context"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceGithubActionsPublicKey() *schema.Resource {
@@ -40,8 +40,14 @@ func dataSourceGithubActionsPublicKeyRead(d *schema.ResourceData, meta interface
}

d.SetId(publicKey.GetKeyID())
d.Set("key_id", publicKey.GetKeyID())
d.Set("key", publicKey.GetKey())
err = d.Set("key_id", publicKey.GetKeyID())
if err != nil {
return err
}
err = d.Set("key", publicKey.GetKey())
if err != nil {
return err
}

return nil
}
Loading

0 comments on commit 09831f5

Please sign in to comment.