Updates for terraform-plugin-framework v0.7.0 (#40)

Reference: https://github.com/hashicorp/terraform-plugin-framework/releases/tag/v0.7.0
This commit is contained in:
Brian Flad 2022-04-29 16:02:22 -04:00 committed by GitHub
parent 2db8ff9bdd
commit 16a0751849
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 12 deletions

View File

@ -13,6 +13,7 @@ import (
// Ensure provider defined types fully satisfy framework interfaces // Ensure provider defined types fully satisfy framework interfaces
var _ tfsdk.ResourceType = exampleResourceType{} var _ tfsdk.ResourceType = exampleResourceType{}
var _ tfsdk.Resource = exampleResource{} var _ tfsdk.Resource = exampleResource{}
var _ tfsdk.ResourceWithImportState = exampleResource{}
type exampleResourceType struct{} type exampleResourceType struct{}
@ -148,8 +149,6 @@ func (r exampleResource) Delete(ctx context.Context, req tfsdk.DeleteResourceReq
// resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to delete example, got error: %s", err)) // resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to delete example, got error: %s", err))
// return // return
// } // }
resp.State.RemoveResource(ctx)
} }
func (r exampleResource) ImportState(ctx context.Context, req tfsdk.ImportResourceStateRequest, resp *tfsdk.ImportResourceStateResponse) { func (r exampleResource) ImportState(ctx context.Context, req tfsdk.ImportResourceStateRequest, resp *tfsdk.ImportResourceStateResponse) {

View File

@ -3,7 +3,7 @@ package provider
import ( import (
"testing" "testing"
"github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/hashicorp/terraform-plugin-go/tfprotov6" "github.com/hashicorp/terraform-plugin-go/tfprotov6"
) )
@ -12,9 +12,7 @@ import (
// CLI command executed to create a provider server to which the CLI can // CLI command executed to create a provider server to which the CLI can
// reattach. // reattach.
var testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){ var testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){
"scaffolding": func() (tfprotov6.ProviderServer, error) { "scaffolding": providerserver.NewProtocol6WithError(New("test")()),
return tfsdk.NewProtocol6Server(New("test")()), nil
},
} }
func testAccPreCheck(t *testing.T) { func testAccPreCheck(t *testing.T) {

11
main.go
View File

@ -5,7 +5,7 @@ import (
"flag" "flag"
"log" "log"
"github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/providerserver"
"github.com/hashicorp/terraform-provider-scaffolding-framework/internal/provider" "github.com/hashicorp/terraform-provider-scaffolding-framework/internal/provider"
) )
@ -34,14 +34,13 @@ func main() {
flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve") flag.BoolVar(&debug, "debug", false, "set to true to run the provider with support for debuggers like delve")
flag.Parse() flag.Parse()
opts := tfsdk.ServeOpts{ opts := providerserver.ServeOpts{
Debug: debug,
// TODO: Update this string with the published name of your provider. // TODO: Update this string with the published name of your provider.
Name: "registry.terraform.io/hashicorp/scaffolding", Address: "registry.terraform.io/hashicorp/scaffolding",
Debug: debug,
} }
err := tfsdk.Serve(context.Background(), provider.New(version), opts) err := providerserver.Serve(context.Background(), provider.New(version), opts)
if err != nil { if err != nil {
log.Fatal(err.Error()) log.Fatal(err.Error())