Skip to content

Commit

Permalink
migrate code to tf-plugin-framework v0.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Hoß authored and sebhoss committed Aug 12, 2022
1 parent 255cb1d commit e54287a
Show file tree
Hide file tree
Showing 31 changed files with 154 additions and 125 deletions.
2 changes: 1 addition & 1 deletion internal/provider/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"time"
)

func protoV6ProviderFactories() map[string]func() (tfprotov6.ProviderServer, error) {
func testProviderFactories() map[string]func() (tfprotov6.ProviderServer, error) {
return map[string]func() (tfprotov6.ProviderServer, error){
"git": providerserver.NewProtocol6WithError(provider.New()),
}
Expand Down
6 changes: 4 additions & 2 deletions internal/provider/data_source_git_branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import (
"context"
"github.com/go-git/go-git/v5/plumbing"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
Expand Down Expand Up @@ -76,13 +78,13 @@ func (r *dataSourceGitBranchType) GetSchema(_ context.Context) (tfsdk.Schema, di
}, nil
}

func (r *dataSourceGitBranchType) NewDataSource(_ context.Context, p tfsdk.Provider) (tfsdk.DataSource, diag.Diagnostics) {
func (r *dataSourceGitBranchType) NewDataSource(_ context.Context, p provider.Provider) (datasource.DataSource, diag.Diagnostics) {
return &dataSourceGitBranch{
p: *(p.(*gitProvider)),
}, nil
}

func (r *dataSourceGitBranch) Read(ctx context.Context, req tfsdk.ReadDataSourceRequest, resp *tfsdk.ReadDataSourceResponse) {
func (r *dataSourceGitBranch) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
tflog.Debug(ctx, "Reading Git repository branch")

var inputs dataSourceGitBranchSchema
Expand Down
10 changes: 5 additions & 5 deletions internal/provider/data_source_git_branch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TestDataSourceGitBranch(t *testing.T) {
})

resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
Expand All @@ -54,7 +54,7 @@ func TestDataSourceGitBranch(t *testing.T) {
func TestDataSourceGitBranch_InvalidRepository(t *testing.T) {
t.Parallel()
resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: `
Expand All @@ -75,7 +75,7 @@ func TestDataSourceGitBranch_InvalidBranch(t *testing.T) {
defer os.RemoveAll(directory)

resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
Expand All @@ -96,7 +96,7 @@ func TestDataSourceGitBranch_MissingBranch(t *testing.T) {
defer os.RemoveAll(directory)

resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
Expand All @@ -113,7 +113,7 @@ func TestDataSourceGitBranch_MissingBranch(t *testing.T) {
func TestDataSourceGitBranch_MissingRepository(t *testing.T) {
t.Parallel()
resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: `
Expand Down
6 changes: 4 additions & 2 deletions internal/provider/data_source_git_branches.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import (
"github.com/go-git/go-git/v5/plumbing"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
Expand Down Expand Up @@ -73,13 +75,13 @@ func (r *dataSourceGitBranchesType) GetSchema(_ context.Context) (tfsdk.Schema,
}, nil
}

func (r *dataSourceGitBranchesType) NewDataSource(_ context.Context, p tfsdk.Provider) (tfsdk.DataSource, diag.Diagnostics) {
func (r *dataSourceGitBranchesType) NewDataSource(_ context.Context, p provider.Provider) (datasource.DataSource, diag.Diagnostics) {
return &dataSourceGitBranches{
p: *(p.(*gitProvider)),
}, nil
}

func (r *dataSourceGitBranches) Read(ctx context.Context, req tfsdk.ReadDataSourceRequest, resp *tfsdk.ReadDataSourceResponse) {
func (r *dataSourceGitBranches) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
tflog.Debug(ctx, "Reading Git repository branches")

var inputs dataSourceGitBranchesSchema
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/data_source_git_branches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestDataSourceGitBranches(t *testing.T) {
testAddAndCommitNewFile(t, worktree, "some-file")

resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
Expand All @@ -47,7 +47,7 @@ func TestDataSourceGitBranches(t *testing.T) {
func TestDataSourceGitBranches_InvalidRepository(t *testing.T) {
t.Parallel()
resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: `
Expand All @@ -64,7 +64,7 @@ func TestDataSourceGitBranches_InvalidRepository(t *testing.T) {
func TestDataSourceGitBranches_MissingRepository(t *testing.T) {
t.Parallel()
resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: `
Expand Down
6 changes: 4 additions & 2 deletions internal/provider/data_source_git_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import (
"context"
"github.com/go-git/go-git/v5/plumbing"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
Expand Down Expand Up @@ -120,13 +122,13 @@ func (r *dataSourceGitCommitType) GetSchema(_ context.Context) (tfsdk.Schema, di
}, nil
}

func (r *dataSourceGitCommitType) NewDataSource(_ context.Context, p tfsdk.Provider) (tfsdk.DataSource, diag.Diagnostics) {
func (r *dataSourceGitCommitType) NewDataSource(_ context.Context, p provider.Provider) (datasource.DataSource, diag.Diagnostics) {
return &dataSourceGitCommit{
p: *(p.(*gitProvider)),
}, nil
}

func (r *dataSourceGitCommit) Read(ctx context.Context, req tfsdk.ReadDataSourceRequest, resp *tfsdk.ReadDataSourceResponse) {
func (r *dataSourceGitCommit) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
tflog.Debug(ctx, "Reading Git commit information")

var inputs dataSourceGitCommitSchema
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/data_source_git_commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestDataSourceGitCommit(t *testing.T) {
commit := testGitCommit(t, worktree)

resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
Expand Down
6 changes: 4 additions & 2 deletions internal/provider/data_source_git_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ package provider
import (
"context"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
Expand Down Expand Up @@ -102,13 +104,13 @@ func (r *dataSourceGitConfigType) GetSchema(_ context.Context) (tfsdk.Schema, di
}, nil
}

func (r *dataSourceGitConfigType) NewDataSource(_ context.Context, p tfsdk.Provider) (tfsdk.DataSource, diag.Diagnostics) {
func (r *dataSourceGitConfigType) NewDataSource(_ context.Context, p provider.Provider) (datasource.DataSource, diag.Diagnostics) {
return &dataSourceGitConfig{
p: *(p.(*gitProvider)),
}, nil
}

func (r *dataSourceGitConfig) Read(ctx context.Context, req tfsdk.ReadDataSourceRequest, resp *tfsdk.ReadDataSourceResponse) {
func (r *dataSourceGitConfig) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
tflog.Debug(ctx, "Reading Git repository configuration")

var inputs dataSourceGitConfigSchema
Expand Down
14 changes: 7 additions & 7 deletions internal/provider/data_source_git_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestDataSourceGitConfig(t *testing.T) {
cfg := testConfig(t, repository)

resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
Expand All @@ -49,7 +49,7 @@ func TestDataSourceGitConfig(t *testing.T) {
func TestDataSourceGitConfig_InvalidRepository(t *testing.T) {
t.Parallel()
resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: `
Expand All @@ -69,7 +69,7 @@ func TestDataSourceGitConfig_InvalidScope(t *testing.T) {
defer os.RemoveAll(directory)

resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
Expand All @@ -91,7 +91,7 @@ func TestDataSourceGitConfig_ScopeLocal(t *testing.T) {
cfg := testConfig(t, repository)

resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
Expand Down Expand Up @@ -123,7 +123,7 @@ func TestDataSourceGitConfig_ScopeGlobal(t *testing.T) {
cfg := testConfig(t, repository)

resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
Expand Down Expand Up @@ -155,7 +155,7 @@ func TestDataSourceGitConfig_ScopeSystem(t *testing.T) {
cfg := testConfig(t, repository)

resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
Expand Down Expand Up @@ -183,7 +183,7 @@ func TestDataSourceGitConfig_ScopeSystem(t *testing.T) {
func TestDataSourceGitConfig_MissingRepository(t *testing.T) {
t.Parallel()
resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: `
Expand Down
6 changes: 4 additions & 2 deletions internal/provider/data_source_git_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ package provider
import (
"context"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
Expand Down Expand Up @@ -65,13 +67,13 @@ func (r *dataSourceGitRemoteType) GetSchema(_ context.Context) (tfsdk.Schema, di
}, nil
}

func (r *dataSourceGitRemoteType) NewDataSource(_ context.Context, p tfsdk.Provider) (tfsdk.DataSource, diag.Diagnostics) {
func (r *dataSourceGitRemoteType) NewDataSource(_ context.Context, p provider.Provider) (datasource.DataSource, diag.Diagnostics) {
return &dataSourceGitRemote{
p: *(p.(*gitProvider)),
}, nil
}

func (r *dataSourceGitRemote) Read(ctx context.Context, req tfsdk.ReadDataSourceRequest, resp *tfsdk.ReadDataSourceResponse) {
func (r *dataSourceGitRemote) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
tflog.Debug(ctx, "Reading Git repository remote")

var inputs dataSourceGitRemoteSchema
Expand Down
10 changes: 5 additions & 5 deletions internal/provider/data_source_git_remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestDataSourceGitRemote(t *testing.T) {
testCreateRemote(t, repository, remote)

resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
Expand All @@ -46,7 +46,7 @@ func TestDataSourceGitRemote(t *testing.T) {
func TestDataSourceGitRemote_InvalidRepository(t *testing.T) {
t.Parallel()
resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: `
Expand All @@ -67,7 +67,7 @@ func TestDataSourceGitRemote_InvalidRemote(t *testing.T) {
defer os.RemoveAll(directory)

resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
Expand All @@ -88,7 +88,7 @@ func TestDataSourceGitRemote_MissingRemote(t *testing.T) {
defer os.RemoveAll(directory)

resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
Expand All @@ -105,7 +105,7 @@ func TestDataSourceGitRemote_MissingRemote(t *testing.T) {
func TestDataSourceGitRemote_MissingRepository(t *testing.T) {
t.Parallel()
resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: `
Expand Down
6 changes: 4 additions & 2 deletions internal/provider/data_source_git_remotes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import (
"context"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
Expand Down Expand Up @@ -63,13 +65,13 @@ func (r *dataSourceGitRemotesType) GetSchema(_ context.Context) (tfsdk.Schema, d
}, nil
}

func (r *dataSourceGitRemotesType) NewDataSource(_ context.Context, p tfsdk.Provider) (tfsdk.DataSource, diag.Diagnostics) {
func (r *dataSourceGitRemotesType) NewDataSource(_ context.Context, p provider.Provider) (datasource.DataSource, diag.Diagnostics) {
return &dataSourceGitRemotes{
p: *(p.(*gitProvider)),
}, nil
}

func (r *dataSourceGitRemotes) Read(ctx context.Context, req tfsdk.ReadDataSourceRequest, resp *tfsdk.ReadDataSourceResponse) {
func (r *dataSourceGitRemotes) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
tflog.Debug(ctx, "Reading Git repository remotes")

var inputs dataSourceGitRemotesSchema
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/data_source_git_remotes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestDataSourceGitRemotes(t *testing.T) {
testCreateRemote(t, repository, remote)

resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: fmt.Sprintf(`
Expand All @@ -45,7 +45,7 @@ func TestDataSourceGitRemotes(t *testing.T) {
func TestDataSourceGitRemotes_InvalidRepository(t *testing.T) {
t.Parallel()
resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: `
Expand All @@ -62,7 +62,7 @@ func TestDataSourceGitRemotes_InvalidRepository(t *testing.T) {
func TestDataSourceGitRemotes_MissingRepository(t *testing.T) {
t.Parallel()
resource.UnitTest(t, resource.TestCase{
ProtoV6ProviderFactories: protoV6ProviderFactories(),
ProtoV6ProviderFactories: testProviderFactories(),
Steps: []resource.TestStep{
{
Config: `
Expand Down
Loading

0 comments on commit e54287a

Please sign in to comment.