Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

Commit

Permalink
plugin: Update tfsdk.NewProtocol6Server usage with new providerserver…
Browse files Browse the repository at this point in the history
  • Loading branch information
bflad authored Apr 28, 2022
1 parent b4aca5e commit f67a9d2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 27 deletions.
9 changes: 3 additions & 6 deletions content/plugin/framework/acctests.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,15 @@ to supply a map of functions that return a
To get a `tfprotov6.ProviderServer` from a
[`tfsdk.Provider`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/tfsdk#Provider),
you need to use the
[`tfsdk.NewProtocol6Server`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/tfsdk#NewProtocol6Server)
[`providerserver.NewProtocol6WithError`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/providerserver#NewProtocol6WithError)
helper. For example:

```go
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: map[string]func() (tfprotov6.ProviderServer, error) {
"example_provider": func() (tfprotov6.ProviderServer, error) {
// newProvider is your function that returns a
// tfsdk.Provider implementation
return tfsdk.NewProtocol6Server(newProvider()), nil
},
// newProvider is your function that returns a tfsdk.Provider
"example_provider": providerserver.NewProtocol6WithError(newProvider()),
},
CheckDestroy: testAccCheckExampleResourceDestroy,
Steps: []resource.TestStep{
Expand Down
16 changes: 4 additions & 12 deletions content/plugin/mux/combining-protocol-version-6-providers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,8 @@ func main() {
ctx := context.Background()
providers := []func() tfprotov6.ProviderServer{
// Example terraform-plugin-framework providers
func() tfprotov6.ProviderServer {
return tfsdk.NewProtocol6Server(provider1.New("test")())
},
func() tfprotov6.ProviderServer {
return tfsdk.NewProtocol6Server(provider2.New("test")())
},
providerserver.NewProtocol6(provider1.New("test")())
providerserver.NewProtocol6(provider2.New("test")())
}

muxServer, err := tf6muxserver.NewMuxServer(ctx, providers...)
Expand Down Expand Up @@ -113,12 +109,8 @@ resource.Test(t, resource.TestCase{
ctx := context.Background()
providers := []func() tfprotov6.ProviderServer{
// Example terraform-plugin-framework providers
func() tfprotov6.ProviderServer {
return tfsdk.NewProtocol6Server(provider1.New("test")())
},
func() tfprotov6.ProviderServer {
return tfsdk.NewProtocol6Server(provider2.New("test")())
},
providerserver.NewProtocol6(provider1.New("test")())
providerserver.NewProtocol6(provider2.New("test")())
}

muxServer, err := tf6muxserver.NewMuxServer(ctx, providers...)
Expand Down
4 changes: 1 addition & 3 deletions content/plugin/mux/translating-protocol-version-5-to-6.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ providers := []func() tfprotov6.ProviderServer{
upgradedSdkProvider.ProviderServer,

// Example terraform-plugin-framework provider
func() tfprotov6.ProviderServer {
return tfsdk.NewProtocol6Server(frameworkprovider.New(version)())
},
providerserver.NewProtocol6(frameworkprovider.New(version)())
}

muxServer, err := tf6muxserver.NewMuxServer(ctx, providers...)
Expand Down
8 changes: 2 additions & 6 deletions content/plugin/mux/translating-protocol-version-6-to-5.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ The following example downgrades a `terraform-plugin-framework` provider.
```go
downgradedFrameworkProvider, err := tf6to5server.DowngradeServer(
context.Background(),
func() tfprotov6.ProviderServer {
return tfsdk.NewProtocol6Server(frameworkprovider.New(version)())
},
providerserver.NewProtocol6(frameworkprovider.New(version)())
)
```

Expand Down Expand Up @@ -81,9 +79,7 @@ resource.Test(t, resource.TestCase{
ctx := context.Background()
downgradedFrameworkProvider, err := tf6to5server.DowngradeServer(
ctx,
func() tfprotov6.ProviderServer {
return tfsdk.NewProtocol6Server(frameworkprovider.New("test")())
},
providerserver.NewProtocol6(frameworkprovider.New("test")())
)

if err != nil {
Expand Down

1 comment on commit f67a9d2

@vercel
Copy link

@vercel vercel bot commented on f67a9d2 Apr 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.