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

Upgrade to Terraform Plugin SDK v2 #1780

Merged
merged 33 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9e5e9a1
go mod tidy -go=1.16 && go mod tidy -go=1.17
kfcampbell Jul 7, 2023
eac9585
Run go mod vendor
kfcampbell Jul 7, 2023
c29bb37
Attempt v2 upgrade
kfcampbell Jul 7, 2023
28b5e1d
Plugin compiling
kfcampbell Jul 7, 2023
29f699d
Fix some provider test errors
kfcampbell Jul 7, 2023
40f2d11
Merge branch 'main' into go-mod-tidy-fixes
kfcampbell Jul 11, 2023
010281e
Fix test compilation error
kfcampbell Jul 11, 2023
725f560
ValidateFunc --> ValidateDiagFunc
kfcampbell Jul 11, 2023
f9fc1ef
Fix casing
kfcampbell Jul 11, 2023
984ea4d
Sprinkle toDiagFunc everywhere
kfcampbell Jul 11, 2023
78328f9
More fixes for validation functions
kfcampbell Jul 12, 2023
b6fe875
State --> StateContext
kfcampbell Jul 12, 2023
40a4d76
%s --> %v when printing diags
kfcampbell Jul 12, 2023
2df74c0
ConfigureFunc --> ConfigureContextFunc
kfcampbell Jul 12, 2023
bd524eb
Checking results of d.Set, round one
kfcampbell Jul 12, 2023
649e074
Continue checking d.Set results
kfcampbell Jul 12, 2023
2aea5e5
Check results of d.Set, round three
kfcampbell Jul 12, 2023
31e3418
Checking d.Set results, round four
kfcampbell Jul 12, 2023
c6267b6
d.Set round five
kfcampbell Jul 12, 2023
7611cfd
In tests, export GITHUB_TEST_ORGANIZATION
kfcampbell Jul 12, 2023
e1f7240
Remove unnecessary MaxItems on computed value
kfcampbell Jul 12, 2023
34b1b54
Merge main. Take all incoming changes. Build not yet functional.
kfcampbell Jan 11, 2024
8d17c01
Go build now works
kfcampbell Jan 11, 2024
732dd81
Resolve linting errors
kfcampbell Jan 11, 2024
3c01b80
Merge branch 'v6' into go-mod-tidy-fixes
kfcampbell Jan 11, 2024
f5da116
Apply diag.FromErr twice more
kfcampbell Jan 11, 2024
556c712
Pass key names into toDiagFunc helper
kfcampbell Jan 11, 2024
4702422
Construct cty.Path from strings
kfcampbell Jan 11, 2024
1596fe5
Tests now working
kfcampbell Jan 16, 2024
c49ac7e
Merge branch 'v6' into go-mod-tidy-fixes
kfcampbell Jan 16, 2024
a9040f4
Update terraform-plugin-sdk version
kfcampbell Jan 16, 2024
f69a04b
Merge branch 'v6' into go-mod-tidy-fixes
kfcampbell Jan 16, 2024
8cc7846
Remove commented attribute setting in resource_github_team.go
kfcampbell Jan 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

7 changes: 4 additions & 3 deletions github/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -40,7 +40,7 @@ func RateLimitedHTTPClient(client *http.Client, writeDelay time.Duration, readDe

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",
Expand Down Expand Up @@ -137,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
Expand All @@ -160,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 {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_actions_environment_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
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
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion github/data_source_github_actions_environment_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
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 {
Expand Down Expand Up @@ -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
Expand Up @@ -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) {
Expand Down
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
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Up @@ -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) {
Expand Down
7 changes: 5 additions & 2 deletions github/data_source_github_actions_organization_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Up @@ -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) {
Expand Down
7 changes: 5 additions & 2 deletions github/data_source_github_actions_organization_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Up @@ -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) {
Expand Down
12 changes: 9 additions & 3 deletions github/data_source_github_actions_public_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions github/data_source_github_actions_public_key_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 TestAccGithubActionsPublicKeyDataSource(t *testing.T) {
Expand Down
12 changes: 9 additions & 3 deletions github/data_source_github_actions_registration_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 dataSourceGithubActionsRegistrationToken() *schema.Resource {
Expand Down Expand Up @@ -42,8 +42,14 @@ func dataSourceGithubActionsRegistrationTokenRead(d *schema.ResourceData, meta i
}

d.SetId(fmt.Sprintf("%s/%s", owner, repoName))
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
}
4 changes: 2 additions & 2 deletions github/data_source_github_actions_registration_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 TestAccGithubActionsRegistrationTokenDataSource(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package github

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

func dataSourceGithubActionsRepositoryOIDCSubjectClaimCustomizationTemplate() *schema.Resource {
return &schema.Resource{
Expand Down Expand Up @@ -40,8 +40,14 @@ func dataSourceGithubActionsRepositoryOIDCSubjectClaimCustomizationTemplateRead(
}

d.SetId(repository)
d.Set("use_default", template.UseDefault)
d.Set("include_claim_keys", template.IncludeClaimKeys)
err = d.Set("use_default", template.UseDefault)
if err != nil {
return err
}
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
Expand Up @@ -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 TestAccGithubActionsRepositoryOIDCSubjectClaimCustomizationTemplateDataSource(t *testing.T) {
Expand Down
7 changes: 5 additions & 2 deletions github/data_source_github_actions_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,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 dataSourceGithubActionsSecrets() *schema.Resource {
Expand Down Expand Up @@ -96,7 +96,10 @@ func dataSourceGithubActionsSecretsRead(d *schema.ResourceData, meta interface{}
}

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

return nil
}
4 changes: 2 additions & 2 deletions github/data_source_github_actions_secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 TestAccGithubActionsSecretsDataSource(t *testing.T) {
Expand Down
Loading