internal/provider: Add compilation based interface assertions (#38)
This is a quick method for compilation errors to be raised should the types not satisfy the expected framework interfaces.
This commit is contained in:
parent
3c30204856
commit
51deae2bc7
@ -9,6 +9,10 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Ensure provider defined types fully satisfy framework interfaces
|
||||||
|
var _ tfsdk.DataSourceType = exampleDataSourceType{}
|
||||||
|
var _ tfsdk.DataSource = exampleDataSource{}
|
||||||
|
|
||||||
type exampleDataSourceType struct{}
|
type exampleDataSourceType struct{}
|
||||||
|
|
||||||
func (t exampleDataSourceType) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) {
|
func (t exampleDataSourceType) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) {
|
||||||
|
@ -10,6 +10,10 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-log/tflog"
|
"github.com/hashicorp/terraform-plugin-log/tflog"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Ensure provider defined types fully satisfy framework interfaces
|
||||||
|
var _ tfsdk.ResourceType = exampleResourceType{}
|
||||||
|
var _ tfsdk.Resource = exampleResource{}
|
||||||
|
|
||||||
type exampleResourceType struct{}
|
type exampleResourceType struct{}
|
||||||
|
|
||||||
func (t exampleResourceType) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) {
|
func (t exampleResourceType) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) {
|
||||||
|
@ -9,6 +9,9 @@ import (
|
|||||||
"github.com/hashicorp/terraform-plugin-framework/types"
|
"github.com/hashicorp/terraform-plugin-framework/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Ensure provider defined types fully satisfy framework interfaces
|
||||||
|
var _ tfsdk.Provider = &provider{}
|
||||||
|
|
||||||
// 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 provider struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user