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
var _ tfsdk.ResourceType = exampleResourceType{}
var _ tfsdk.Resource = exampleResource{}
var _ tfsdk.ResourceWithImportState = exampleResource{}
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))
// return
// }
resp.State.RemoveResource(ctx)
}
func (r exampleResource) ImportState(ctx context.Context, req tfsdk.ImportResourceStateRequest, resp *tfsdk.ImportResourceStateResponse) {

View File

@ -3,7 +3,7 @@ package provider
import (
"testing"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
"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
// reattach.
var testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServer, error){
"scaffolding": func() (tfprotov6.ProviderServer, error) {
return tfsdk.NewProtocol6Server(New("test")()), nil
},
"scaffolding": providerserver.NewProtocol6WithError(New("test")()),
}
func testAccPreCheck(t *testing.T) {

11
main.go
View File

@ -5,7 +5,7 @@ import (
"flag"
"log"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/providerserver"
"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.Parse()
opts := tfsdk.ServeOpts{
Debug: debug,
opts := providerserver.ServeOpts{
// 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 {
log.Fatal(err.Error())