Bump github.com/hashicorp/terraform-plugin-framework from 0.10.0 to 0.11.0 (#77)

* Bump github.com/hashicorp/terraform-plugin-framework

Bumps [github.com/hashicorp/terraform-plugin-framework](https://github.com/hashicorp/terraform-plugin-framework) from 0.10.0 to 0.11.0.
- [Release notes](https://github.com/hashicorp/terraform-plugin-framework/releases)
- [Changelog](https://github.com/hashicorp/terraform-plugin-framework/blob/main/CHANGELOG.md)
- [Commits](https://github.com/hashicorp/terraform-plugin-framework/compare/v0.10.0...v0.11.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/terraform-plugin-framework
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Code updates for terraform-plugin-framework v0.11.0

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Brian Flad <bflad417@gmail.com>
This commit is contained in:
dependabot[bot] 2022-08-11 13:03:35 -04:00 committed by GitHub
parent e5808c408d
commit cdfbef8f1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 44 deletions

2
go.mod
View File

@ -4,7 +4,7 @@ go 1.17
require ( require (
github.com/hashicorp/terraform-plugin-docs v0.13.0 github.com/hashicorp/terraform-plugin-docs v0.13.0
github.com/hashicorp/terraform-plugin-framework v0.10.0 github.com/hashicorp/terraform-plugin-framework v0.11.0
github.com/hashicorp/terraform-plugin-go v0.13.0 github.com/hashicorp/terraform-plugin-go v0.13.0
github.com/hashicorp/terraform-plugin-log v0.7.0 github.com/hashicorp/terraform-plugin-log v0.7.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.20.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.20.0

4
go.sum
View File

@ -147,8 +147,8 @@ github.com/hashicorp/terraform-json v0.14.0 h1:sh9iZ1Y8IFJLx+xQiKHGud6/TSUCM0N8e
github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM= github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM=
github.com/hashicorp/terraform-plugin-docs v0.13.0 h1:6e+VIWsVGb6jYJewfzq2ok2smPzZrt1Wlm9koLeKazY= github.com/hashicorp/terraform-plugin-docs v0.13.0 h1:6e+VIWsVGb6jYJewfzq2ok2smPzZrt1Wlm9koLeKazY=
github.com/hashicorp/terraform-plugin-docs v0.13.0/go.mod h1:W0oCmHAjIlTHBbvtppWHe8fLfZ2BznQbuv8+UD8OucQ= github.com/hashicorp/terraform-plugin-docs v0.13.0/go.mod h1:W0oCmHAjIlTHBbvtppWHe8fLfZ2BznQbuv8+UD8OucQ=
github.com/hashicorp/terraform-plugin-framework v0.10.0 h1:LGYcnvNdVaZA1ZHe53BHLVjaaGs7HTiq6+9Js29stL4= github.com/hashicorp/terraform-plugin-framework v0.11.0 h1:NLWMUMNp0HjCjJctNzEv3FJsR/ndYTSbO9XfwlSVFeQ=
github.com/hashicorp/terraform-plugin-framework v0.10.0/go.mod h1:CK7Opzukfu/2CPJs+HzUdfHrFlp+ZIQeSxjF0x8k464= github.com/hashicorp/terraform-plugin-framework v0.11.0/go.mod h1:gVjHP7o0QzWpHe5dvA+GUu+mH0/vQDZeexkkq2RS/II=
github.com/hashicorp/terraform-plugin-go v0.12.0/go.mod h1:kwhmaWHNDvT1B3QiSJdAtrB/D4RaKSY/v3r2BuoWK4M= github.com/hashicorp/terraform-plugin-go v0.12.0/go.mod h1:kwhmaWHNDvT1B3QiSJdAtrB/D4RaKSY/v3r2BuoWK4M=
github.com/hashicorp/terraform-plugin-go v0.13.0 h1:Zm+o91HUOcTLotaEu3X2jV/6wNi6f09gkZwGg/MDvCk= github.com/hashicorp/terraform-plugin-go v0.13.0 h1:Zm+o91HUOcTLotaEu3X2jV/6wNi6f09gkZwGg/MDvCk=
github.com/hashicorp/terraform-plugin-go v0.13.0/go.mod h1:NYGFEM9GeRdSl52txue3RcBDFt2tufaqS22iURP8Bxs= github.com/hashicorp/terraform-plugin-go v0.13.0/go.mod h1:NYGFEM9GeRdSl52txue3RcBDFt2tufaqS22iURP8Bxs=

View File

@ -2,16 +2,18 @@ package provider
import ( import (
"context" "context"
"log"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/diag" "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/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
) )
// Ensure provider defined types fully satisfy framework interfaces // Ensure provider defined types fully satisfy framework interfaces
var _ tfsdk.DataSourceType = exampleDataSourceType{} var _ provider.DataSourceType = exampleDataSourceType{}
var _ tfsdk.DataSource = exampleDataSource{} var _ datasource.DataSource = exampleDataSource{}
type exampleDataSourceType struct{} type exampleDataSourceType struct{}
@ -35,7 +37,7 @@ func (t exampleDataSourceType) GetSchema(ctx context.Context) (tfsdk.Schema, dia
}, nil }, nil
} }
func (t exampleDataSourceType) NewDataSource(ctx context.Context, in tfsdk.Provider) (tfsdk.DataSource, diag.Diagnostics) { func (t exampleDataSourceType) NewDataSource(ctx context.Context, in provider.Provider) (datasource.DataSource, diag.Diagnostics) {
provider, diags := convertProviderType(in) provider, diags := convertProviderType(in)
return exampleDataSource{ return exampleDataSource{
@ -49,23 +51,19 @@ type exampleDataSourceData struct {
} }
type exampleDataSource struct { type exampleDataSource struct {
provider provider provider scaffoldingProvider
} }
func (d exampleDataSource) Read(ctx context.Context, req tfsdk.ReadDataSourceRequest, resp *tfsdk.ReadDataSourceResponse) { func (d exampleDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var data exampleDataSourceData var data exampleDataSourceData
diags := req.Config.Get(ctx, &data) diags := req.Config.Get(ctx, &data)
resp.Diagnostics.Append(diags...) resp.Diagnostics.Append(diags...)
log.Printf("got here")
if resp.Diagnostics.HasError() { if resp.Diagnostics.HasError() {
return return
} }
log.Printf("got here")
// If applicable, this is a great opportunity to initialize any necessary // If applicable, this is a great opportunity to initialize any necessary
// provider client data and make a call using it. // provider client data and make a call using it.
// example, err := d.provider.client.ReadExample(...) // example, err := d.provider.client.ReadExample(...)
@ -78,6 +76,10 @@ func (d exampleDataSource) Read(ctx context.Context, req tfsdk.ReadDataSourceReq
// save into the Terraform state. // save into the Terraform state.
data.Id = types.String{Value: "example-id"} data.Id = types.String{Value: "example-id"}
// Write logs using the tflog package
// Documentation: https://terraform.io/plugin/log
tflog.Trace(ctx, "read a data source")
diags = resp.State.Set(ctx, &data) diags = resp.State.Set(ctx, &data)
resp.Diagnostics.Append(diags...) resp.Diagnostics.Append(diags...)
} }

View File

@ -5,15 +5,17 @@ import (
"github.com/hashicorp/terraform-plugin-framework/diag" "github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/tfsdk" "github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-plugin-log/tflog"
) )
// Ensure provider defined types fully satisfy framework interfaces // Ensure provider defined types fully satisfy framework interfaces
var _ tfsdk.ResourceType = exampleResourceType{} var _ provider.ResourceType = exampleResourceType{}
var _ tfsdk.Resource = exampleResource{} var _ resource.Resource = exampleResource{}
var _ tfsdk.ResourceWithImportState = exampleResource{} var _ resource.ResourceWithImportState = exampleResource{}
type exampleResourceType struct{} type exampleResourceType struct{}
@ -32,7 +34,7 @@ func (t exampleResourceType) GetSchema(ctx context.Context) (tfsdk.Schema, diag.
Computed: true, Computed: true,
MarkdownDescription: "Example identifier", MarkdownDescription: "Example identifier",
PlanModifiers: tfsdk.AttributePlanModifiers{ PlanModifiers: tfsdk.AttributePlanModifiers{
tfsdk.UseStateForUnknown(), resource.UseStateForUnknown(),
}, },
Type: types.StringType, Type: types.StringType,
}, },
@ -40,7 +42,7 @@ func (t exampleResourceType) GetSchema(ctx context.Context) (tfsdk.Schema, diag.
}, nil }, nil
} }
func (t exampleResourceType) NewResource(ctx context.Context, in tfsdk.Provider) (tfsdk.Resource, diag.Diagnostics) { func (t exampleResourceType) NewResource(ctx context.Context, in provider.Provider) (resource.Resource, diag.Diagnostics) {
provider, diags := convertProviderType(in) provider, diags := convertProviderType(in)
return exampleResource{ return exampleResource{
@ -54,10 +56,10 @@ type exampleResourceData struct {
} }
type exampleResource struct { type exampleResource struct {
provider provider provider scaffoldingProvider
} }
func (r exampleResource) Create(ctx context.Context, req tfsdk.CreateResourceRequest, resp *tfsdk.CreateResourceResponse) { func (r exampleResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
var data exampleResourceData var data exampleResourceData
diags := req.Config.Get(ctx, &data) diags := req.Config.Get(ctx, &data)
@ -79,16 +81,15 @@ func (r exampleResource) Create(ctx context.Context, req tfsdk.CreateResourceReq
// save into the Terraform state. // save into the Terraform state.
data.Id = types.String{Value: "example-id"} data.Id = types.String{Value: "example-id"}
// write logs using the tflog package // Write logs using the tflog package
// see https://pkg.go.dev/github.com/hashicorp/terraform-plugin-log/tflog // Documentation: https://terraform.io/plugin/log
// for more information
tflog.Trace(ctx, "created a resource") tflog.Trace(ctx, "created a resource")
diags = resp.State.Set(ctx, &data) diags = resp.State.Set(ctx, &data)
resp.Diagnostics.Append(diags...) resp.Diagnostics.Append(diags...)
} }
func (r exampleResource) Read(ctx context.Context, req tfsdk.ReadResourceRequest, resp *tfsdk.ReadResourceResponse) { func (r exampleResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) {
var data exampleResourceData var data exampleResourceData
diags := req.State.Get(ctx, &data) diags := req.State.Get(ctx, &data)
@ -110,7 +111,7 @@ func (r exampleResource) Read(ctx context.Context, req tfsdk.ReadResourceRequest
resp.Diagnostics.Append(diags...) resp.Diagnostics.Append(diags...)
} }
func (r exampleResource) Update(ctx context.Context, req tfsdk.UpdateResourceRequest, resp *tfsdk.UpdateResourceResponse) { func (r exampleResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) {
var data exampleResourceData var data exampleResourceData
diags := req.Plan.Get(ctx, &data) diags := req.Plan.Get(ctx, &data)
@ -132,7 +133,7 @@ func (r exampleResource) Update(ctx context.Context, req tfsdk.UpdateResourceReq
resp.Diagnostics.Append(diags...) resp.Diagnostics.Append(diags...)
} }
func (r exampleResource) Delete(ctx context.Context, req tfsdk.DeleteResourceRequest, resp *tfsdk.DeleteResourceResponse) { func (r exampleResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) {
var data exampleResourceData var data exampleResourceData
diags := req.State.Get(ctx, &data) diags := req.State.Get(ctx, &data)
@ -151,6 +152,6 @@ func (r exampleResource) Delete(ctx context.Context, req tfsdk.DeleteResourceReq
// } // }
} }
func (r exampleResource) ImportState(ctx context.Context, req tfsdk.ImportResourceStateRequest, resp *tfsdk.ImportResourceStateResponse) { func (r exampleResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) {
tfsdk.ResourceImportStatePassthroughID(ctx, path.Root("id"), req, resp) resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp)
} }

View File

@ -5,16 +5,17 @@ import (
"fmt" "fmt"
"github.com/hashicorp/terraform-plugin-framework/diag" "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/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types" "github.com/hashicorp/terraform-plugin-framework/types"
) )
// Ensure provider defined types fully satisfy framework interfaces // Ensure provider defined types fully satisfy framework interfaces
var _ tfsdk.Provider = &provider{} var _ provider.Provider = &scaffoldingProvider{}
// provider satisfies the tfsdk.Provider interface and usually is included // provider satisfies the tfsdk.Provider interface and usually is included
// with all Resource and DataSource implementations. // with all Resource and DataSource implementations.
type provider struct { type scaffoldingProvider struct {
// client can contain the upstream provider SDK or HTTP client used to // client can contain the upstream provider SDK or HTTP client used to
// communicate with the upstream service. Resource and DataSource // communicate with the upstream service. Resource and DataSource
// implementations can then make calls using this client. // implementations can then make calls using this client.
@ -38,7 +39,7 @@ type providerData struct {
Example types.String `tfsdk:"example"` Example types.String `tfsdk:"example"`
} }
func (p *provider) Configure(ctx context.Context, req tfsdk.ConfigureProviderRequest, resp *tfsdk.ConfigureProviderResponse) { func (p *scaffoldingProvider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) {
var data providerData var data providerData
diags := req.Config.Get(ctx, &data) diags := req.Config.Get(ctx, &data)
resp.Diagnostics.Append(diags...) resp.Diagnostics.Append(diags...)
@ -56,19 +57,19 @@ func (p *provider) Configure(ctx context.Context, req tfsdk.ConfigureProviderReq
p.configured = true p.configured = true
} }
func (p *provider) GetResources(ctx context.Context) (map[string]tfsdk.ResourceType, diag.Diagnostics) { func (p *scaffoldingProvider) GetResources(ctx context.Context) (map[string]provider.ResourceType, diag.Diagnostics) {
return map[string]tfsdk.ResourceType{ return map[string]provider.ResourceType{
"scaffolding_example": exampleResourceType{}, "scaffolding_example": exampleResourceType{},
}, nil }, nil
} }
func (p *provider) GetDataSources(ctx context.Context) (map[string]tfsdk.DataSourceType, diag.Diagnostics) { func (p *scaffoldingProvider) GetDataSources(ctx context.Context) (map[string]provider.DataSourceType, diag.Diagnostics) {
return map[string]tfsdk.DataSourceType{ return map[string]provider.DataSourceType{
"scaffolding_example": exampleDataSourceType{}, "scaffolding_example": exampleDataSourceType{},
}, nil }, nil
} }
func (p *provider) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { func (p *scaffoldingProvider) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) {
return tfsdk.Schema{ return tfsdk.Schema{
Attributes: map[string]tfsdk.Attribute{ Attributes: map[string]tfsdk.Attribute{
"example": { "example": {
@ -80,9 +81,9 @@ func (p *provider) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostic
}, nil }, nil
} }
func New(version string) func() tfsdk.Provider { func New(version string) func() provider.Provider {
return func() tfsdk.Provider { return func() provider.Provider {
return &provider{ return &scaffoldingProvider{
version: version, version: version,
} }
} }
@ -91,19 +92,19 @@ func New(version string) func() tfsdk.Provider {
// convertProviderType is a helper function for NewResource and NewDataSource // convertProviderType is a helper function for NewResource and NewDataSource
// implementations to associate the concrete provider type. Alternatively, // implementations to associate the concrete provider type. Alternatively,
// this helper can be skipped and the provider type can be directly type // this helper can be skipped and the provider type can be directly type
// asserted (e.g. provider: in.(*provider)), however using this can prevent // asserted (e.g. provider: in.(*scaffoldingProvider)), however using this can prevent
// potential panics. // potential panics.
func convertProviderType(in tfsdk.Provider) (provider, diag.Diagnostics) { func convertProviderType(in provider.Provider) (scaffoldingProvider, diag.Diagnostics) {
var diags diag.Diagnostics var diags diag.Diagnostics
p, ok := in.(*provider) p, ok := in.(*scaffoldingProvider)
if !ok { if !ok {
diags.AddError( diags.AddError(
"Unexpected Provider Instance Type", "Unexpected Provider Instance Type",
fmt.Sprintf("While creating the data source or resource, an unexpected provider type (%T) was received. This is always a bug in the provider code and should be reported to the provider developers.", p), fmt.Sprintf("While creating the data source or resource, an unexpected provider type (%T) was received. This is always a bug in the provider code and should be reported to the provider developers.", p),
) )
return provider{}, diags return scaffoldingProvider{}, diags
} }
if p == nil { if p == nil {
@ -111,7 +112,7 @@ func convertProviderType(in tfsdk.Provider) (provider, diag.Diagnostics) {
"Unexpected Provider Instance Type", "Unexpected Provider Instance Type",
"While creating the data source or resource, an unexpected empty provider instance was received. This is always a bug in the provider code and should be reported to the provider developers.", "While creating the data source or resource, an unexpected empty provider instance was received. This is always a bug in the provider code and should be reported to the provider developers.",
) )
return provider{}, diags return scaffoldingProvider{}, diags
} }
return *p, diags return *p, diags