From 43327b7518674090d3ca1a4384d79f0811533964 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Fri, 9 Sep 2022 13:38:28 -0400 Subject: [PATCH] datasource+resource: Rename TypeName method to Metadata --- .changelog/472.txt | 14 +- datasource/data_source.go | 14 +- datasource/{type_name.go => metadata.go} | 14 +- internal/fwserver/server.go | 24 +-- .../fwserver/server_getproviderschema_test.go | 68 +++---- .../server_upgraderesourcestate_test.go | 8 +- .../server_validatedatasourceconfig_test.go | 8 +- .../server_validateresourceconfig_test.go | 8 +- .../server_applyresourcechange_test.go | 84 ++++----- .../server_getproviderschema_test.go | 60 +++---- .../server_importresourcestate_test.go | 16 +- .../server_planresourcechange_test.go | 72 ++++---- .../server_readdatasource_test.go | 20 +-- .../proto5server/server_readresource_test.go | 32 ++-- .../server_upgraderesourcestate_test.go | 12 +- .../server_validatedatasourceconfig_test.go | 12 +- .../server_validateresourcetypeconfig_test.go | 12 +- .../server_applyresourcechange_test.go | 84 ++++----- .../server_getproviderschema_test.go | 60 +++---- .../server_importresourcestate_test.go | 16 +- .../server_planresourcechange_test.go | 72 ++++---- .../server_readdatasource_test.go | 20 +-- .../proto6server/server_readresource_test.go | 32 ++-- .../server_upgraderesourcestate_test.go | 12 +- .../server_validatedataresourceconfig_test.go | 12 +- .../server_validateresourceconfig_test.go | 12 +- .../datasourcewithgetschema_temp.go | 76 ++++---- .../testprovider/datasourcewithmetadata.go | 27 +++ .../testprovider/datasourcewithtypename.go | 27 --- .../resourcewithgetschema_temp.go | 166 +++++++++--------- .../testprovider/resourcewithmetadata.go | 27 +++ .../testprovider/resourcewithtypename.go | 27 --- provider/data_source_type.go | 2 +- provider/provider.go | 8 +- provider/resource_type.go | 2 +- resource/{type_name.go => metadata.go} | 14 +- resource/resource.go | 14 +- .../plugin/framework/data-sources/index.mdx | 12 +- .../docs/plugin/framework/resources/index.mdx | 12 +- 39 files changed, 606 insertions(+), 606 deletions(-) rename datasource/{type_name.go => metadata.go} (58%) create mode 100644 internal/testing/testprovider/datasourcewithmetadata.go delete mode 100644 internal/testing/testprovider/datasourcewithtypename.go create mode 100644 internal/testing/testprovider/resourcewithmetadata.go delete mode 100644 internal/testing/testprovider/resourcewithtypename.go rename resource/{type_name.go => metadata.go} (58%) diff --git a/.changelog/472.txt b/.changelog/472.txt index 14bce2fe5..a17d92501 100644 --- a/.changelog/472.txt +++ b/.changelog/472.txt @@ -1,5 +1,5 @@ ```release-note:enhancement -datasource: The `DataSource` type `GetSchema` and `TypeName` methods will be required in the next version. +datasource: The `DataSource` type `GetSchema` and `Metadata` methods will be required in the next version. ``` ```release-note:note @@ -7,11 +7,11 @@ provider: The `DataSourceType` type has been deprecated in preference of moving ``` ```release-note:note -provider: The `Provider` type `GetDataSources` method has been deprecated in preference of the `DataSources` method. All `datasource.DataSource` types must implement the `TypeName` method after migrating. Support for the `GetDataSources` method will be removed in the next version. +provider: The `Provider` type `GetDataSources` method has been deprecated in preference of the `DataSources` method. All `datasource.DataSource` types must implement the `Metadata` method after migrating. Support for the `GetDataSources` method will be removed in the next version. ``` ```release-note:note -provider: The `Provider` type `GetResources` method has been deprecated in preference of the `Resources` method. All `resource.Resource` types must implement the `TypeName` method after migrating. Support for the `GetResources` method will be removed in the next version. +provider: The `Provider` type `GetResources` method has been deprecated in preference of the `Resources` method. All `resource.Resource` types must implement the `Metadata` method after migrating. Support for the `GetResources` method will be removed in the next version. ``` ```release-note:note @@ -19,11 +19,11 @@ provider: The `ResourceType` type has been deprecated in preference of moving th ``` ```release-note:enhancement -resource: The `Resource` type `GetSchema` and `TypeName` methods will be required in the next version. +resource: The `Resource` type `GetSchema` and `Metadata` methods will be required in the next version. ``` ```release-note:enhancement -datasource: Added `DataSource` type `Configure`, `GetSchema`, and `TypeName` method support +datasource: Added `DataSource` type `Configure`, `GetSchema`, and `Metadata` method support ``` ```release-note:enhancement @@ -35,9 +35,9 @@ provider: Added `ConfigureResponse` type `ResourceData` field, which will set th ``` ```release-note:enhancement -provider: Added `Provider` type `Metadata` method support, which the `MetadataResponse.TypeName` field will set the `datasource.TypeNameRequest.ProviderTypeName` and `resource.TypeNameRequest.ProviderTypeName` fields +provider: Added `Provider` type `Metadata` method support, which the `MetadataResponse.TypeName` field will set the `datasource.MetadataRequest.ProviderTypeName` and `resource.MetadataRequest.ProviderTypeName` fields ``` ```release-note:enhancement -resource: Added `Resource` type `Configure`, `GetSchema`, and `TypeName` method support +resource: Added `Resource` type `Configure`, `GetSchema`, and `Metadata` method support ``` diff --git a/datasource/data_source.go b/datasource/data_source.go index 5d5c78874..0d74ab11e 100644 --- a/datasource/data_source.go +++ b/datasource/data_source.go @@ -63,18 +63,18 @@ type DataSourceWithGetSchema interface { GetSchema(context.Context) (tfsdk.Schema, diag.Diagnostics) } -// DataSourceWithTypeName is an interface type that extends DataSource to -// return its data source type name. For example, if the provider is named -// examplecloud and the data source reads a thing, this should return -// examplecloud_thing. +// DataSourceWithMetadata is an interface type that extends DataSource to +// return metadata, such as its data source type name. For example, if the +// provider is named examplecloud and the data source reads a thing, this +// should return examplecloud_thing. // // This method will be required in the DataSource interface a future release. -type DataSourceWithTypeName interface { +type DataSourceWithMetadata interface { DataSource - // TypeName should return the full name of the data source, such as + // Metadata should return the full name of the data source, such as // examplecloud_thing. - TypeName(context.Context, TypeNameRequest, *TypeNameResponse) + Metadata(context.Context, MetadataRequest, *MetadataResponse) } // DataSourceWithValidateConfig is an interface type that extends DataSource to include imperative validation. diff --git a/datasource/type_name.go b/datasource/metadata.go similarity index 58% rename from datasource/type_name.go rename to datasource/metadata.go index 116f7b034..37aef828d 100644 --- a/datasource/type_name.go +++ b/datasource/metadata.go @@ -1,9 +1,9 @@ package datasource -// TypeNameRequest represents a request for the DataSource to return its type -// name. An instance of this request struct is supplied as an argument to the -// DataSource type TypeName method. -type TypeNameRequest struct { +// MetadataRequest represents a request for the DataSource to return metadata, +// such as its type name. An instance of this request struct is supplied as an +// argument to the DataSource type Metadata method. +type MetadataRequest struct { // ProviderTypeName is the string returned from // [provider.MetadataResponse.TypeName], if the Provider type implements // the Metadata method. This string should prefix the DataSource type name @@ -11,10 +11,10 @@ type TypeNameRequest struct { ProviderTypeName string } -// TypeNameResponse represents a response to a TypeNameRequest. An +// MetadataResponse represents a response to a MetadataRequest. An // instance of this response struct is supplied as an argument to the -// DataSource type TypeName method. -type TypeNameResponse struct { +// DataSource type Metadata method. +type MetadataResponse struct { // TypeName should be the full data source type, including the provider // type prefix and an underscore. For example, examplecloud_thing. TypeName string diff --git a/internal/fwserver/server.go b/internal/fwserver/server.go index d678a4e41..85e73bcd5 100644 --- a/internal/fwserver/server.go +++ b/internal/fwserver/server.go @@ -186,28 +186,28 @@ func (s *Server) DataSourceFuncs(ctx context.Context) (map[string]func() datasou for _, dataSourceFunc := range dataSourceFuncsSlice { dataSource := dataSourceFunc() - dataSourceWithTypeName, ok := dataSource.(datasource.DataSourceWithTypeName) + dataSourceWithMetadata, ok := dataSource.(datasource.DataSourceWithMetadata) if !ok { s.dataSourceTypesDiags.AddError( "Data Source Type Name Missing", - fmt.Sprintf("The %T DataSource in the provider DataSources method results is missing the TypeName method. ", dataSource)+ + fmt.Sprintf("The %T DataSource in the provider DataSources method results is missing the Metadata method. ", dataSource)+ "This is always an issue with the provider and should be reported to the provider developers.", ) continue } - dataSourceTypeNameReq := datasource.TypeNameRequest{ + dataSourceTypeNameReq := datasource.MetadataRequest{ ProviderTypeName: s.providerTypeName, } - dataSourceTypeNameResp := datasource.TypeNameResponse{} + dataSourceTypeNameResp := datasource.MetadataResponse{} - dataSourceWithTypeName.TypeName(ctx, dataSourceTypeNameReq, &dataSourceTypeNameResp) + dataSourceWithMetadata.Metadata(ctx, dataSourceTypeNameReq, &dataSourceTypeNameResp) if dataSourceTypeNameResp.TypeName == "" { s.dataSourceTypesDiags.AddError( "Data Source Type Name Missing", - fmt.Sprintf("The %T DataSource returned an empty string from the TypeName method. ", dataSource)+ + fmt.Sprintf("The %T DataSource returned an empty string from the Metadata method. ", dataSource)+ "This is always an issue with the provider and should be reported to the provider developers.", ) continue @@ -460,28 +460,28 @@ func (s *Server) ResourceFuncs(ctx context.Context) (map[string]func() resource. for _, resourceFunc := range resourceFuncsSlice { res := resourceFunc() - resourceWithTypeName, ok := res.(resource.ResourceWithTypeName) + resourceWithMetadata, ok := res.(resource.ResourceWithMetadata) if !ok { s.resourceTypesDiags.AddError( "Resource Type Name Missing", - fmt.Sprintf("The %T Resource in the provider Resources method results is missing the TypeName method. ", res)+ + fmt.Sprintf("The %T Resource in the provider Resources method results is missing the Metadata method. ", res)+ "This is always an issue with the provider and should be reported to the provider developers.", ) continue } - resourceTypeNameReq := resource.TypeNameRequest{ + resourceTypeNameReq := resource.MetadataRequest{ ProviderTypeName: s.providerTypeName, } - resourceTypeNameResp := resource.TypeNameResponse{} + resourceTypeNameResp := resource.MetadataResponse{} - resourceWithTypeName.TypeName(ctx, resourceTypeNameReq, &resourceTypeNameResp) + resourceWithMetadata.Metadata(ctx, resourceTypeNameReq, &resourceTypeNameResp) if resourceTypeNameResp.TypeName == "" { s.resourceTypesDiags.AddError( "Resource Type Name Missing", - fmt.Sprintf("The %T Resource returned an empty string from the TypeName method. ", res)+ + fmt.Sprintf("The %T Resource returned an empty string from the Metadata method. ", res)+ "This is always an issue with the provider and should be reported to the provider developers.", ) continue diff --git a/internal/fwserver/server_getproviderschema_test.go b/internal/fwserver/server_getproviderschema_test.go index fbf485472..89b89a14e 100644 --- a/internal/fwserver/server_getproviderschema_test.go +++ b/internal/fwserver/server_getproviderschema_test.go @@ -43,7 +43,7 @@ func TestServerGetProviderSchema(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -54,13 +54,13 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source1" }, } }, func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -71,7 +71,7 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source2" }, } @@ -113,7 +113,7 @@ func TestServerGetProviderSchema(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -124,13 +124,13 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, } }, func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -141,7 +141,7 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, } @@ -174,8 +174,8 @@ func TestServerGetProviderSchema(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithTypeName{ - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + return &testprovider.DataSourceWithMetadata{ + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "" }, } @@ -190,7 +190,7 @@ func TestServerGetProviderSchema(t *testing.T) { Diagnostics: diag.Diagnostics{ diag.NewErrorDiagnostic( "Data Source Type Name Missing", - "The *testprovider.DataSourceWithTypeName DataSource returned an empty string from the TypeName method. "+ + "The *testprovider.DataSourceWithMetadata DataSource returned an empty string from the Metadata method. "+ "This is always an issue with the provider and should be reported to the provider developers.", ), }, @@ -207,8 +207,8 @@ func TestServerGetProviderSchema(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithTypeName{ - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + return &testprovider.DataSourceWithMetadata{ + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, } @@ -223,7 +223,7 @@ func TestServerGetProviderSchema(t *testing.T) { Diagnostics: diag.Diagnostics{ diag.NewErrorDiagnostic( "Data Source Schema Missing", - "The *testprovider.DataSourceWithTypeName DataSource in the provider is missing the GetSchema method. "+ + "The *testprovider.DataSourceWithMetadata DataSource in the provider is missing the GetSchema method. "+ "This is always an issue with the provider and should be reported to the provider developers.", ), }, @@ -263,7 +263,7 @@ func TestServerGetProviderSchema(t *testing.T) { Diagnostics: diag.Diagnostics{ diag.NewErrorDiagnostic( "Data Source Type Name Missing", - "The *testprovider.DataSourceWithGetSchema DataSource in the provider DataSources method results is missing the TypeName method. "+ + "The *testprovider.DataSourceWithGetSchema DataSource in the provider DataSources method results is missing the Metadata method. "+ "This is always an issue with the provider and should be reported to the provider developers.", ), }, @@ -284,7 +284,7 @@ func TestServerGetProviderSchema(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -295,7 +295,7 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, req datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = req.ProviderTypeName + "_data_source" }, } @@ -518,7 +518,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -529,13 +529,13 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource1" }, } }, func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -546,7 +546,7 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource2" }, } @@ -588,7 +588,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -599,13 +599,13 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, } }, func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -616,7 +616,7 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, } @@ -649,8 +649,8 @@ func TestServerGetProviderSchema(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithTypeName{ - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + return &testprovider.ResourceWithMetadata{ + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "" }, } @@ -665,7 +665,7 @@ func TestServerGetProviderSchema(t *testing.T) { Diagnostics: diag.Diagnostics{ diag.NewErrorDiagnostic( "Resource Type Name Missing", - "The *testprovider.ResourceWithTypeName Resource returned an empty string from the TypeName method. "+ + "The *testprovider.ResourceWithMetadata Resource returned an empty string from the Metadata method. "+ "This is always an issue with the provider and should be reported to the provider developers.", ), }, @@ -682,8 +682,8 @@ func TestServerGetProviderSchema(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithTypeName{ - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + return &testprovider.ResourceWithMetadata{ + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_data_source" }, } @@ -698,7 +698,7 @@ func TestServerGetProviderSchema(t *testing.T) { Diagnostics: diag.Diagnostics{ diag.NewErrorDiagnostic( "Resource Schema Missing", - "The *testprovider.ResourceWithTypeName Resource in the provider is missing the GetSchema method. "+ + "The *testprovider.ResourceWithMetadata Resource in the provider is missing the GetSchema method. "+ "This is always an issue with the provider and should be reported to the provider developers.", ), }, @@ -738,7 +738,7 @@ func TestServerGetProviderSchema(t *testing.T) { Diagnostics: diag.Diagnostics{ diag.NewErrorDiagnostic( "Resource Type Name Missing", - "The *testprovider.ResourceWithGetSchema Resource in the provider Resources method results is missing the TypeName method. "+ + "The *testprovider.ResourceWithGetSchema Resource in the provider Resources method results is missing the Metadata method. "+ "This is always an issue with the provider and should be reported to the provider developers.", ), }, @@ -759,7 +759,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -770,7 +770,7 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, req resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = req.ProviderTypeName + "_resource" }, } diff --git a/internal/fwserver/server_upgraderesourcestate_test.go b/internal/fwserver/server_upgraderesourcestate_test.go index 5e2f9758f..da22756ad 100644 --- a/internal/fwserver/server_upgraderesourcestate_test.go +++ b/internal/fwserver/server_upgraderesourcestate_test.go @@ -645,11 +645,11 @@ func TestServerUpgradeResourceState(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return schema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, } @@ -687,11 +687,11 @@ func TestServerUpgradeResourceState(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return schema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, } diff --git a/internal/fwserver/server_validatedatasourceconfig_test.go b/internal/fwserver/server_validatedatasourceconfig_test.go index 10a6016e4..7b914ede2 100644 --- a/internal/fwserver/server_validatedatasourceconfig_test.go +++ b/internal/fwserver/server_validatedatasourceconfig_test.go @@ -161,7 +161,7 @@ func TestServerValidateDataSourceConfig(t *testing.T) { }, request: &fwserver.ValidateDataSourceConfigRequest{ Config: &testConfig, - DataSource: &testprovider.DataSourceWithConfigValidatorsAndGetSchemaAndTypeName{ + DataSource: &testprovider.DataSourceWithConfigValidatorsAndGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, @@ -195,7 +195,7 @@ func TestServerValidateDataSourceConfig(t *testing.T) { }, request: &fwserver.ValidateDataSourceConfigRequest{ Config: &testConfig, - DataSource: &testprovider.DataSourceWithConfigValidatorsAndGetSchemaAndTypeName{ + DataSource: &testprovider.DataSourceWithConfigValidatorsAndGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, @@ -225,7 +225,7 @@ func TestServerValidateDataSourceConfig(t *testing.T) { }, request: &fwserver.ValidateDataSourceConfigRequest{ Config: &testConfig, - DataSource: &testprovider.DataSourceWithGetSchemaAndTypeNameAndValidateConfig{ + DataSource: &testprovider.DataSourceWithGetSchemaAndMetadataAndValidateConfig{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, @@ -253,7 +253,7 @@ func TestServerValidateDataSourceConfig(t *testing.T) { }, request: &fwserver.ValidateDataSourceConfigRequest{ Config: &testConfig, - DataSource: &testprovider.DataSourceWithGetSchemaAndTypeNameAndValidateConfig{ + DataSource: &testprovider.DataSourceWithGetSchemaAndMetadataAndValidateConfig{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, diff --git a/internal/fwserver/server_validateresourceconfig_test.go b/internal/fwserver/server_validateresourceconfig_test.go index 9bfbdac11..1ab356023 100644 --- a/internal/fwserver/server_validateresourceconfig_test.go +++ b/internal/fwserver/server_validateresourceconfig_test.go @@ -161,7 +161,7 @@ func TestServerValidateResourceConfig(t *testing.T) { }, request: &fwserver.ValidateResourceConfigRequest{ Config: &testConfig, - Resource: &testprovider.ResourceWithConfigValidatorsAndGetSchemaAndTypeName{ + Resource: &testprovider.ResourceWithConfigValidatorsAndGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, @@ -195,7 +195,7 @@ func TestServerValidateResourceConfig(t *testing.T) { }, request: &fwserver.ValidateResourceConfigRequest{ Config: &testConfig, - Resource: &testprovider.ResourceWithConfigValidatorsAndGetSchemaAndTypeName{ + Resource: &testprovider.ResourceWithConfigValidatorsAndGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, @@ -225,7 +225,7 @@ func TestServerValidateResourceConfig(t *testing.T) { }, request: &fwserver.ValidateResourceConfigRequest{ Config: &testConfig, - Resource: &testprovider.ResourceWithGetSchemaAndTypeNameAndValidateConfig{ + Resource: &testprovider.ResourceWithGetSchemaAndMetadataAndValidateConfig{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, @@ -253,7 +253,7 @@ func TestServerValidateResourceConfig(t *testing.T) { }, request: &fwserver.ValidateResourceConfigRequest{ Config: &testConfig, - Resource: &testprovider.ResourceWithGetSchemaAndTypeNameAndValidateConfig{ + Resource: &testprovider.ResourceWithGetSchemaAndMetadataAndValidateConfig{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, diff --git a/internal/proto5server/server_applyresourcechange_test.go b/internal/proto5server/server_applyresourcechange_test.go index e2e85296f..f3a2bf7b1 100644 --- a/internal/proto5server/server_applyresourcechange_test.go +++ b/internal/proto5server/server_applyresourcechange_test.go @@ -84,11 +84,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -144,11 +144,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -205,11 +205,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -273,11 +273,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -334,11 +334,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -388,11 +388,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -446,11 +446,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -498,11 +498,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -549,11 +549,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -604,11 +604,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -660,11 +660,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -720,11 +720,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -764,11 +764,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -826,11 +826,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -888,11 +888,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -950,11 +950,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -1017,11 +1017,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -1091,11 +1091,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -1158,11 +1158,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -1215,11 +1215,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -1274,11 +1274,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ diff --git a/internal/proto5server/server_getproviderschema_test.go b/internal/proto5server/server_getproviderschema_test.go index 834a5bbe8..cfd8c72c5 100644 --- a/internal/proto5server/server_getproviderschema_test.go +++ b/internal/proto5server/server_getproviderschema_test.go @@ -36,7 +36,7 @@ func TestServerGetProviderSchema(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -47,13 +47,13 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source1" }, } }, func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -64,7 +64,7 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source2" }, } @@ -116,7 +116,7 @@ func TestServerGetProviderSchema(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -127,13 +127,13 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, } }, func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -144,7 +144,7 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, } @@ -182,8 +182,8 @@ func TestServerGetProviderSchema(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithTypeName{ - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + return &testprovider.DataSourceWithMetadata{ + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "" }, } @@ -200,7 +200,7 @@ func TestServerGetProviderSchema(t *testing.T) { { Severity: tfprotov5.DiagnosticSeverityError, Summary: "Data Source Type Name Missing", - Detail: "The *testprovider.DataSourceWithTypeName DataSource returned an empty string from the TypeName method. " + + Detail: "The *testprovider.DataSourceWithMetadata DataSource returned an empty string from the Metadata method. " + "This is always an issue with the provider and should be reported to the provider developers.", }, }, @@ -220,8 +220,8 @@ func TestServerGetProviderSchema(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithTypeName{ - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + return &testprovider.DataSourceWithMetadata{ + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, } @@ -238,7 +238,7 @@ func TestServerGetProviderSchema(t *testing.T) { { Severity: tfprotov5.DiagnosticSeverityError, Summary: "Data Source Schema Missing", - Detail: "The *testprovider.DataSourceWithTypeName DataSource in the provider is missing the GetSchema method. " + + Detail: "The *testprovider.DataSourceWithMetadata DataSource in the provider is missing the GetSchema method. " + "This is always an issue with the provider and should be reported to the provider developers.", }, }, @@ -283,7 +283,7 @@ func TestServerGetProviderSchema(t *testing.T) { { Severity: tfprotov5.DiagnosticSeverityError, Summary: "Data Source Type Name Missing", - Detail: "The *testprovider.DataSourceWithGetSchema DataSource in the provider DataSources method results is missing the TypeName method. " + + Detail: "The *testprovider.DataSourceWithGetSchema DataSource in the provider DataSources method results is missing the Metadata method. " + "This is always an issue with the provider and should be reported to the provider developers.", }, }, @@ -452,7 +452,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -463,13 +463,13 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource1" }, } }, func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -480,7 +480,7 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource2" }, } @@ -532,7 +532,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -543,13 +543,13 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, } }, func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -560,7 +560,7 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, } @@ -598,8 +598,8 @@ func TestServerGetProviderSchema(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithTypeName{ - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + return &testprovider.ResourceWithMetadata{ + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "" }, } @@ -616,7 +616,7 @@ func TestServerGetProviderSchema(t *testing.T) { { Severity: tfprotov5.DiagnosticSeverityError, Summary: "Resource Type Name Missing", - Detail: "The *testprovider.ResourceWithTypeName Resource returned an empty string from the TypeName method. " + + Detail: "The *testprovider.ResourceWithMetadata Resource returned an empty string from the Metadata method. " + "This is always an issue with the provider and should be reported to the provider developers.", }, }, @@ -636,8 +636,8 @@ func TestServerGetProviderSchema(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithTypeName{ - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + return &testprovider.ResourceWithMetadata{ + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, } @@ -654,7 +654,7 @@ func TestServerGetProviderSchema(t *testing.T) { { Severity: tfprotov5.DiagnosticSeverityError, Summary: "Resource Schema Missing", - Detail: "The *testprovider.ResourceWithTypeName Resource in the provider is missing the GetSchema method. " + + Detail: "The *testprovider.ResourceWithMetadata Resource in the provider is missing the GetSchema method. " + "This is always an issue with the provider and should be reported to the provider developers.", }, }, @@ -699,7 +699,7 @@ func TestServerGetProviderSchema(t *testing.T) { { Severity: tfprotov5.DiagnosticSeverityError, Summary: "Resource Type Name Missing", - Detail: "The *testprovider.ResourceWithGetSchema Resource in the provider Resources method results is missing the TypeName method. " + + Detail: "The *testprovider.ResourceWithGetSchema Resource in the provider Resources method results is missing the Metadata method. " + "This is always an issue with the provider and should be reported to the provider developers.", }, }, diff --git a/internal/proto5server/server_importresourcestate_test.go b/internal/proto5server/server_importresourcestate_test.go index 61e2c9649..63204f87c 100644 --- a/internal/proto5server/server_importresourcestate_test.go +++ b/internal/proto5server/server_importresourcestate_test.go @@ -65,11 +65,11 @@ func TestServerImportResourceState(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndImportStateAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndImportStateAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, @@ -107,11 +107,11 @@ func TestServerImportResourceState(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndImportStateAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndImportStateAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, @@ -152,11 +152,11 @@ func TestServerImportResourceState(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndImportStateAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndImportStateAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, @@ -190,11 +190,11 @@ func TestServerImportResourceState(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndImportStateAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndImportStateAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, diff --git a/internal/proto5server/server_planresourcechange_test.go b/internal/proto5server/server_planresourcechange_test.go index 482d9c10e..29f7e88b1 100644 --- a/internal/proto5server/server_planresourcechange_test.go +++ b/internal/proto5server/server_planresourcechange_test.go @@ -82,11 +82,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -131,11 +131,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -181,11 +181,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -235,11 +235,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -291,11 +291,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -340,11 +340,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -394,11 +394,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -437,11 +437,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -484,11 +484,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -533,11 +533,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -582,11 +582,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -629,11 +629,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -681,11 +681,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -733,11 +733,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -786,11 +786,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -843,11 +843,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -902,11 +902,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -954,11 +954,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { diff --git a/internal/proto5server/server_readdatasource_test.go b/internal/proto5server/server_readdatasource_test.go index e92d1de63..ff3a46158 100644 --- a/internal/proto5server/server_readdatasource_test.go +++ b/internal/proto5server/server_readdatasource_test.go @@ -63,11 +63,11 @@ func TestServerReadDataSource(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{}, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, DataSource: &testprovider.DataSource{}, @@ -93,11 +93,11 @@ func TestServerReadDataSource(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, DataSource: &testprovider.DataSource{ @@ -137,11 +137,11 @@ func TestServerReadDataSource(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{}, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, DataSource: &testprovider.DataSource{ @@ -185,11 +185,11 @@ func TestServerReadDataSource(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, DataSource: &testprovider.DataSource{ @@ -232,11 +232,11 @@ func TestServerReadDataSource(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, DataSource: &testprovider.DataSource{ diff --git a/internal/proto5server/server_readresource_test.go b/internal/proto5server/server_readresource_test.go index 7934ec730..15c932e13 100644 --- a/internal/proto5server/server_readresource_test.go +++ b/internal/proto5server/server_readresource_test.go @@ -68,11 +68,11 @@ func TestServerReadResource(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{}, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, @@ -98,11 +98,11 @@ func TestServerReadResource(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -142,11 +142,11 @@ func TestServerReadResource(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{}, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -190,11 +190,11 @@ func TestServerReadResource(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{}, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -242,11 +242,11 @@ func TestServerReadResource(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -289,11 +289,11 @@ func TestServerReadResource(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -332,11 +332,11 @@ func TestServerReadResource(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -366,11 +366,11 @@ func TestServerReadResource(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{}, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ diff --git a/internal/proto5server/server_upgraderesourcestate_test.go b/internal/proto5server/server_upgraderesourcestate_test.go index 758bb4ca3..ea61a4ba0 100644 --- a/internal/proto5server/server_upgraderesourcestate_test.go +++ b/internal/proto5server/server_upgraderesourcestate_test.go @@ -60,11 +60,11 @@ func TestServerUpgradeResourceState(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeNameAndUpgradeState{ + return &testprovider.ResourceWithGetSchemaAndMetadataAndUpgradeState{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return schema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, @@ -160,11 +160,11 @@ func TestServerUpgradeResourceState(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeNameAndUpgradeState{ + return &testprovider.ResourceWithGetSchemaAndMetadataAndUpgradeState{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return schema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, @@ -215,11 +215,11 @@ func TestServerUpgradeResourceState(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeNameAndUpgradeState{ + return &testprovider.ResourceWithGetSchemaAndMetadataAndUpgradeState{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return schema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, diff --git a/internal/proto5server/server_validatedatasourceconfig_test.go b/internal/proto5server/server_validatedatasourceconfig_test.go index 4fa4bab89..e83d953af 100644 --- a/internal/proto5server/server_validatedatasourceconfig_test.go +++ b/internal/proto5server/server_validatedatasourceconfig_test.go @@ -56,11 +56,11 @@ func TestServerValidateDataSourceConfig(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{}, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, DataSource: &testprovider.DataSource{}, @@ -83,11 +83,11 @@ func TestServerValidateDataSourceConfig(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, DataSource: &testprovider.DataSource{}, @@ -111,11 +111,11 @@ func TestServerValidateDataSourceConfig(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeNameAndValidateConfig{ + return &testprovider.DataSourceWithGetSchemaAndMetadataAndValidateConfig{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, DataSource: &testprovider.DataSource{}, diff --git a/internal/proto5server/server_validateresourcetypeconfig_test.go b/internal/proto5server/server_validateresourcetypeconfig_test.go index 21317dc4d..f11059271 100644 --- a/internal/proto5server/server_validateresourcetypeconfig_test.go +++ b/internal/proto5server/server_validateresourcetypeconfig_test.go @@ -56,11 +56,11 @@ func TestServerValidateResourceTypeConfig(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{}, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, @@ -83,11 +83,11 @@ func TestServerValidateResourceTypeConfig(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, @@ -111,11 +111,11 @@ func TestServerValidateResourceTypeConfig(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeNameAndValidateConfig{ + return &testprovider.ResourceWithGetSchemaAndMetadataAndValidateConfig{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, diff --git a/internal/proto6server/server_applyresourcechange_test.go b/internal/proto6server/server_applyresourcechange_test.go index f46e308c0..51389409b 100644 --- a/internal/proto6server/server_applyresourcechange_test.go +++ b/internal/proto6server/server_applyresourcechange_test.go @@ -84,11 +84,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -144,11 +144,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -205,11 +205,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -273,11 +273,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -334,11 +334,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -388,11 +388,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -446,11 +446,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -498,11 +498,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -549,11 +549,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -604,11 +604,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -660,11 +660,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -720,11 +720,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -764,11 +764,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -826,11 +826,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -888,11 +888,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -950,11 +950,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -1017,11 +1017,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -1091,11 +1091,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -1158,11 +1158,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -1215,11 +1215,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -1274,11 +1274,11 @@ func TestServerApplyResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ diff --git a/internal/proto6server/server_getproviderschema_test.go b/internal/proto6server/server_getproviderschema_test.go index c5b7b3bce..bc9816fe6 100644 --- a/internal/proto6server/server_getproviderschema_test.go +++ b/internal/proto6server/server_getproviderschema_test.go @@ -36,7 +36,7 @@ func TestServerGetProviderSchema(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -47,13 +47,13 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source1" }, } }, func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -64,7 +64,7 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source2" }, } @@ -116,7 +116,7 @@ func TestServerGetProviderSchema(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -127,13 +127,13 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, } }, func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -144,7 +144,7 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, } @@ -182,8 +182,8 @@ func TestServerGetProviderSchema(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithTypeName{ - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + return &testprovider.DataSourceWithMetadata{ + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "" }, } @@ -200,7 +200,7 @@ func TestServerGetProviderSchema(t *testing.T) { { Severity: tfprotov6.DiagnosticSeverityError, Summary: "Data Source Type Name Missing", - Detail: "The *testprovider.DataSourceWithTypeName DataSource returned an empty string from the TypeName method. " + + Detail: "The *testprovider.DataSourceWithMetadata DataSource returned an empty string from the Metadata method. " + "This is always an issue with the provider and should be reported to the provider developers.", }, }, @@ -220,8 +220,8 @@ func TestServerGetProviderSchema(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithTypeName{ - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + return &testprovider.DataSourceWithMetadata{ + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, } @@ -238,7 +238,7 @@ func TestServerGetProviderSchema(t *testing.T) { { Severity: tfprotov6.DiagnosticSeverityError, Summary: "Data Source Schema Missing", - Detail: "The *testprovider.DataSourceWithTypeName DataSource in the provider is missing the GetSchema method. " + + Detail: "The *testprovider.DataSourceWithMetadata DataSource in the provider is missing the GetSchema method. " + "This is always an issue with the provider and should be reported to the provider developers.", }, }, @@ -283,7 +283,7 @@ func TestServerGetProviderSchema(t *testing.T) { { Severity: tfprotov6.DiagnosticSeverityError, Summary: "Data Source Type Name Missing", - Detail: "The *testprovider.DataSourceWithGetSchema DataSource in the provider DataSources method results is missing the TypeName method. " + + Detail: "The *testprovider.DataSourceWithGetSchema DataSource in the provider DataSources method results is missing the Metadata method. " + "This is always an issue with the provider and should be reported to the provider developers.", }, }, @@ -452,7 +452,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -463,13 +463,13 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource1" }, } }, func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -480,7 +480,7 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource2" }, } @@ -532,7 +532,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -543,13 +543,13 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, } }, func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{ Attributes: map[string]tfsdk.Attribute{ @@ -560,7 +560,7 @@ func TestServerGetProviderSchema(t *testing.T) { }, }, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, } @@ -598,8 +598,8 @@ func TestServerGetProviderSchema(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithTypeName{ - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + return &testprovider.ResourceWithMetadata{ + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "" }, } @@ -616,7 +616,7 @@ func TestServerGetProviderSchema(t *testing.T) { { Severity: tfprotov6.DiagnosticSeverityError, Summary: "Resource Type Name Missing", - Detail: "The *testprovider.ResourceWithTypeName Resource returned an empty string from the TypeName method. " + + Detail: "The *testprovider.ResourceWithMetadata Resource returned an empty string from the Metadata method. " + "This is always an issue with the provider and should be reported to the provider developers.", }, }, @@ -636,8 +636,8 @@ func TestServerGetProviderSchema(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithTypeName{ - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + return &testprovider.ResourceWithMetadata{ + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, } @@ -654,7 +654,7 @@ func TestServerGetProviderSchema(t *testing.T) { { Severity: tfprotov6.DiagnosticSeverityError, Summary: "Resource Schema Missing", - Detail: "The *testprovider.ResourceWithTypeName Resource in the provider is missing the GetSchema method. " + + Detail: "The *testprovider.ResourceWithMetadata Resource in the provider is missing the GetSchema method. " + "This is always an issue with the provider and should be reported to the provider developers.", }, }, @@ -699,7 +699,7 @@ func TestServerGetProviderSchema(t *testing.T) { { Severity: tfprotov6.DiagnosticSeverityError, Summary: "Resource Type Name Missing", - Detail: "The *testprovider.ResourceWithGetSchema Resource in the provider Resources method results is missing the TypeName method. " + + Detail: "The *testprovider.ResourceWithGetSchema Resource in the provider Resources method results is missing the Metadata method. " + "This is always an issue with the provider and should be reported to the provider developers.", }, }, diff --git a/internal/proto6server/server_importresourcestate_test.go b/internal/proto6server/server_importresourcestate_test.go index cfbdd06f3..cb8807f37 100644 --- a/internal/proto6server/server_importresourcestate_test.go +++ b/internal/proto6server/server_importresourcestate_test.go @@ -65,11 +65,11 @@ func TestServerImportResourceState(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndImportStateAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndImportStateAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, @@ -107,11 +107,11 @@ func TestServerImportResourceState(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndImportStateAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndImportStateAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, @@ -152,11 +152,11 @@ func TestServerImportResourceState(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndImportStateAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndImportStateAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, @@ -190,11 +190,11 @@ func TestServerImportResourceState(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndImportStateAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndImportStateAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, diff --git a/internal/proto6server/server_planresourcechange_test.go b/internal/proto6server/server_planresourcechange_test.go index c65abcc08..0ff05ea36 100644 --- a/internal/proto6server/server_planresourcechange_test.go +++ b/internal/proto6server/server_planresourcechange_test.go @@ -82,11 +82,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -131,11 +131,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -181,11 +181,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -235,11 +235,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -291,11 +291,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -340,11 +340,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -394,11 +394,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -437,11 +437,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -484,11 +484,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -533,11 +533,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -582,11 +582,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -629,11 +629,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -681,11 +681,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -733,11 +733,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -786,11 +786,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -843,11 +843,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -902,11 +902,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { @@ -954,11 +954,11 @@ func TestServerPlanResourceChange(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndModifyPlanAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndModifyPlanAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, ModifyPlanMethod: func(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { diff --git a/internal/proto6server/server_readdatasource_test.go b/internal/proto6server/server_readdatasource_test.go index ceda6d48a..1743a42b0 100644 --- a/internal/proto6server/server_readdatasource_test.go +++ b/internal/proto6server/server_readdatasource_test.go @@ -63,11 +63,11 @@ func TestServerReadDataSource(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{}, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, DataSource: &testprovider.DataSource{}, @@ -93,11 +93,11 @@ func TestServerReadDataSource(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, DataSource: &testprovider.DataSource{ @@ -137,11 +137,11 @@ func TestServerReadDataSource(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{}, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, DataSource: &testprovider.DataSource{ @@ -185,11 +185,11 @@ func TestServerReadDataSource(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, DataSource: &testprovider.DataSource{ @@ -232,11 +232,11 @@ func TestServerReadDataSource(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, DataSource: &testprovider.DataSource{ diff --git a/internal/proto6server/server_readresource_test.go b/internal/proto6server/server_readresource_test.go index 9bc70b5f3..d3f611f45 100644 --- a/internal/proto6server/server_readresource_test.go +++ b/internal/proto6server/server_readresource_test.go @@ -68,11 +68,11 @@ func TestServerReadResource(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{}, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, @@ -98,11 +98,11 @@ func TestServerReadResource(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -142,11 +142,11 @@ func TestServerReadResource(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{}, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -190,11 +190,11 @@ func TestServerReadResource(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{}, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -242,11 +242,11 @@ func TestServerReadResource(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -289,11 +289,11 @@ func TestServerReadResource(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -332,11 +332,11 @@ func TestServerReadResource(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ @@ -366,11 +366,11 @@ func TestServerReadResource(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{}, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{ diff --git a/internal/proto6server/server_upgraderesourcestate_test.go b/internal/proto6server/server_upgraderesourcestate_test.go index d3caaf8c2..dfd595df6 100644 --- a/internal/proto6server/server_upgraderesourcestate_test.go +++ b/internal/proto6server/server_upgraderesourcestate_test.go @@ -60,11 +60,11 @@ func TestServerUpgradeResourceState(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeNameAndUpgradeState{ + return &testprovider.ResourceWithGetSchemaAndMetadataAndUpgradeState{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return schema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, @@ -160,11 +160,11 @@ func TestServerUpgradeResourceState(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeNameAndUpgradeState{ + return &testprovider.ResourceWithGetSchemaAndMetadataAndUpgradeState{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return schema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, @@ -215,11 +215,11 @@ func TestServerUpgradeResourceState(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeNameAndUpgradeState{ + return &testprovider.ResourceWithGetSchemaAndMetadataAndUpgradeState{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return schema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, diff --git a/internal/proto6server/server_validatedataresourceconfig_test.go b/internal/proto6server/server_validatedataresourceconfig_test.go index 01461d8a9..43b1f151d 100644 --- a/internal/proto6server/server_validatedataresourceconfig_test.go +++ b/internal/proto6server/server_validatedataresourceconfig_test.go @@ -56,11 +56,11 @@ func TestServerValidateDataResourceConfig(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{}, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, DataSource: &testprovider.DataSource{}, @@ -83,11 +83,11 @@ func TestServerValidateDataResourceConfig(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeName{ + return &testprovider.DataSourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, DataSource: &testprovider.DataSource{}, @@ -111,11 +111,11 @@ func TestServerValidateDataResourceConfig(t *testing.T) { DataSourcesMethod: func(_ context.Context) []func() datasource.DataSource { return []func() datasource.DataSource{ func() datasource.DataSource { - return &testprovider.DataSourceWithGetSchemaAndTypeNameAndValidateConfig{ + return &testprovider.DataSourceWithGetSchemaAndMetadataAndValidateConfig{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "test_data_source" }, DataSource: &testprovider.DataSource{}, diff --git a/internal/proto6server/server_validateresourceconfig_test.go b/internal/proto6server/server_validateresourceconfig_test.go index 088a30936..8c9fcf24b 100644 --- a/internal/proto6server/server_validateresourceconfig_test.go +++ b/internal/proto6server/server_validateresourceconfig_test.go @@ -56,11 +56,11 @@ func TestServerValidateResourceConfig(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return tfsdk.Schema{}, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, @@ -83,11 +83,11 @@ func TestServerValidateResourceConfig(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeName{ + return &testprovider.ResourceWithGetSchemaAndMetadata{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, @@ -111,11 +111,11 @@ func TestServerValidateResourceConfig(t *testing.T) { ResourcesMethod: func(_ context.Context) []func() resource.Resource { return []func() resource.Resource{ func() resource.Resource { - return &testprovider.ResourceWithGetSchemaAndTypeNameAndValidateConfig{ + return &testprovider.ResourceWithGetSchemaAndMetadataAndValidateConfig{ GetSchemaMethod: func(_ context.Context) (tfsdk.Schema, diag.Diagnostics) { return testSchema, nil }, - TypeNameMethod: func(_ context.Context, _ resource.TypeNameRequest, resp *resource.TypeNameResponse) { + MetadataMethod: func(_ context.Context, _ resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "test_resource" }, Resource: &testprovider.Resource{}, diff --git a/internal/testing/testprovider/datasourcewithgetschema_temp.go b/internal/testing/testprovider/datasourcewithgetschema_temp.go index d352de13a..b9b1a05bf 100644 --- a/internal/testing/testprovider/datasourcewithgetschema_temp.go +++ b/internal/testing/testprovider/datasourcewithgetschema_temp.go @@ -8,16 +8,16 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" ) -// This file contains temporary types until GetSchema and TypeName are required +// This file contains temporary types until GetSchema and Metadata are required // in DataSource. -var _ datasource.DataSource = &DataSourceWithConfigValidatorsAndGetSchemaAndTypeName{} -var _ datasource.DataSourceWithConfigValidators = &DataSourceWithConfigValidatorsAndGetSchemaAndTypeName{} -var _ datasource.DataSourceWithGetSchema = &DataSourceWithConfigValidatorsAndGetSchemaAndTypeName{} -var _ datasource.DataSourceWithTypeName = &DataSourceWithConfigValidatorsAndGetSchemaAndTypeName{} +var _ datasource.DataSource = &DataSourceWithConfigValidatorsAndGetSchemaAndMetadata{} +var _ datasource.DataSourceWithConfigValidators = &DataSourceWithConfigValidatorsAndGetSchemaAndMetadata{} +var _ datasource.DataSourceWithGetSchema = &DataSourceWithConfigValidatorsAndGetSchemaAndMetadata{} +var _ datasource.DataSourceWithMetadata = &DataSourceWithConfigValidatorsAndGetSchemaAndMetadata{} // Declarative datasource.DataSourceWithGetSchema for unit testing. -type DataSourceWithConfigValidatorsAndGetSchemaAndTypeName struct { +type DataSourceWithConfigValidatorsAndGetSchemaAndMetadata struct { *DataSource // DataSourceWithConfigValidators interface methods @@ -26,12 +26,12 @@ type DataSourceWithConfigValidatorsAndGetSchemaAndTypeName struct { // DataSourceWithGetSchema interface methods GetSchemaMethod func(context.Context) (tfsdk.Schema, diag.Diagnostics) - // DataSourceWithTypeName interface methods - TypeNameMethod func(context.Context, datasource.TypeNameRequest, *datasource.TypeNameResponse) + // DataSourceWithMetadata interface methods + MetadataMethod func(context.Context, datasource.MetadataRequest, *datasource.MetadataResponse) } // ConfigValidators satisfies the datasource.DataSourceWithConfigValidators interface. -func (d *DataSourceWithConfigValidatorsAndGetSchemaAndTypeName) ConfigValidators(ctx context.Context) []datasource.ConfigValidator { +func (d *DataSourceWithConfigValidatorsAndGetSchemaAndMetadata) ConfigValidators(ctx context.Context) []datasource.ConfigValidator { if d.ConfigValidatorsMethod == nil { return nil } @@ -40,7 +40,7 @@ func (d *DataSourceWithConfigValidatorsAndGetSchemaAndTypeName) ConfigValidators } // GetSchema satisfies the datasource.DataSourceWithGetSchema interface. -func (d *DataSourceWithConfigValidatorsAndGetSchemaAndTypeName) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { +func (d *DataSourceWithConfigValidatorsAndGetSchemaAndMetadata) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { if d.GetSchemaMethod == nil { return tfsdk.Schema{}, nil } @@ -48,32 +48,32 @@ func (d *DataSourceWithConfigValidatorsAndGetSchemaAndTypeName) GetSchema(ctx co return d.GetSchemaMethod(ctx) } -// TypeName satisfies the datasource.DataSourceWithTypeName interface. -func (d *DataSourceWithConfigValidatorsAndGetSchemaAndTypeName) TypeName(ctx context.Context, req datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { - if d.TypeNameMethod == nil { +// Metadata satisfies the datasource.DataSourceWithMetadata interface. +func (d *DataSourceWithConfigValidatorsAndGetSchemaAndMetadata) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + if d.MetadataMethod == nil { return } - d.TypeNameMethod(ctx, req, resp) + d.MetadataMethod(ctx, req, resp) } -var _ datasource.DataSource = &DataSourceWithGetSchemaAndTypeName{} -var _ datasource.DataSourceWithGetSchema = &DataSourceWithGetSchemaAndTypeName{} -var _ datasource.DataSourceWithTypeName = &DataSourceWithGetSchemaAndTypeName{} +var _ datasource.DataSource = &DataSourceWithGetSchemaAndMetadata{} +var _ datasource.DataSourceWithGetSchema = &DataSourceWithGetSchemaAndMetadata{} +var _ datasource.DataSourceWithMetadata = &DataSourceWithGetSchemaAndMetadata{} // Declarative datasource.DataSourceWithGetSchema for unit testing. -type DataSourceWithGetSchemaAndTypeName struct { +type DataSourceWithGetSchemaAndMetadata struct { *DataSource // DataSourceWithGetSchema interface methods GetSchemaMethod func(context.Context) (tfsdk.Schema, diag.Diagnostics) - // DataSourceWithTypeName interface methods - TypeNameMethod func(context.Context, datasource.TypeNameRequest, *datasource.TypeNameResponse) + // DataSourceWithMetadata interface methods + MetadataMethod func(context.Context, datasource.MetadataRequest, *datasource.MetadataResponse) } // GetSchema satisfies the datasource.DataSourceWithGetSchema interface. -func (d *DataSourceWithGetSchemaAndTypeName) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { +func (d *DataSourceWithGetSchemaAndMetadata) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { if d.GetSchemaMethod == nil { return tfsdk.Schema{}, nil } @@ -81,36 +81,36 @@ func (d *DataSourceWithGetSchemaAndTypeName) GetSchema(ctx context.Context) (tfs return d.GetSchemaMethod(ctx) } -// TypeName satisfies the datasource.DataSourceWithTypeName interface. -func (d *DataSourceWithGetSchemaAndTypeName) TypeName(ctx context.Context, req datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { - if d.TypeNameMethod == nil { +// Metadata satisfies the datasource.DataSourceWithMetadata interface. +func (d *DataSourceWithGetSchemaAndMetadata) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + if d.MetadataMethod == nil { return } - d.TypeNameMethod(ctx, req, resp) + d.MetadataMethod(ctx, req, resp) } -var _ datasource.DataSource = &DataSourceWithGetSchemaAndTypeNameAndValidateConfig{} -var _ datasource.DataSourceWithGetSchema = &DataSourceWithGetSchemaAndTypeNameAndValidateConfig{} -var _ datasource.DataSourceWithTypeName = &DataSourceWithGetSchemaAndTypeNameAndValidateConfig{} -var _ datasource.DataSourceWithValidateConfig = &DataSourceWithGetSchemaAndTypeNameAndValidateConfig{} +var _ datasource.DataSource = &DataSourceWithGetSchemaAndMetadataAndValidateConfig{} +var _ datasource.DataSourceWithGetSchema = &DataSourceWithGetSchemaAndMetadataAndValidateConfig{} +var _ datasource.DataSourceWithMetadata = &DataSourceWithGetSchemaAndMetadataAndValidateConfig{} +var _ datasource.DataSourceWithValidateConfig = &DataSourceWithGetSchemaAndMetadataAndValidateConfig{} // Declarative datasource.DataSourceWithGetSchema for unit testing. -type DataSourceWithGetSchemaAndTypeNameAndValidateConfig struct { +type DataSourceWithGetSchemaAndMetadataAndValidateConfig struct { *DataSource // DataSourceWithGetSchema interface methods GetSchemaMethod func(context.Context) (tfsdk.Schema, diag.Diagnostics) - // DataSourceWithTypeName interface methods - TypeNameMethod func(context.Context, datasource.TypeNameRequest, *datasource.TypeNameResponse) + // DataSourceWithMetadata interface methods + MetadataMethod func(context.Context, datasource.MetadataRequest, *datasource.MetadataResponse) // DataSourceWithValidateConfig interface methods ValidateConfigMethod func(context.Context, datasource.ValidateConfigRequest, *datasource.ValidateConfigResponse) } // GetSchema satisfies the datasource.DataSourceWithGetSchema interface. -func (d *DataSourceWithGetSchemaAndTypeNameAndValidateConfig) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { +func (d *DataSourceWithGetSchemaAndMetadataAndValidateConfig) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { if d.GetSchemaMethod == nil { return tfsdk.Schema{}, nil } @@ -118,17 +118,17 @@ func (d *DataSourceWithGetSchemaAndTypeNameAndValidateConfig) GetSchema(ctx cont return d.GetSchemaMethod(ctx) } -// TypeName satisfies the datasource.DataSourceWithTypeName interface. -func (d *DataSourceWithGetSchemaAndTypeNameAndValidateConfig) TypeName(ctx context.Context, req datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { - if d.TypeNameMethod == nil { +// Metadata satisfies the datasource.DataSourceWithMetadata interface. +func (d *DataSourceWithGetSchemaAndMetadataAndValidateConfig) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + if d.MetadataMethod == nil { return } - d.TypeNameMethod(ctx, req, resp) + d.MetadataMethod(ctx, req, resp) } // ValidateConfig satisfies the datasource.DataSourceWithValidateConfig interface. -func (d *DataSourceWithGetSchemaAndTypeNameAndValidateConfig) ValidateConfig(ctx context.Context, req datasource.ValidateConfigRequest, resp *datasource.ValidateConfigResponse) { +func (d *DataSourceWithGetSchemaAndMetadataAndValidateConfig) ValidateConfig(ctx context.Context, req datasource.ValidateConfigRequest, resp *datasource.ValidateConfigResponse) { if d.ValidateConfigMethod == nil { return } diff --git a/internal/testing/testprovider/datasourcewithmetadata.go b/internal/testing/testprovider/datasourcewithmetadata.go new file mode 100644 index 000000000..c30f4493b --- /dev/null +++ b/internal/testing/testprovider/datasourcewithmetadata.go @@ -0,0 +1,27 @@ +package testprovider + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/datasource" +) + +var _ datasource.DataSource = &DataSourceWithMetadata{} +var _ datasource.DataSourceWithMetadata = &DataSourceWithMetadata{} + +// Declarative datasource.DataSourceWithMetadata for unit testing. +type DataSourceWithMetadata struct { + *DataSource + + // DataSourceWithMetadata interface methods + MetadataMethod func(context.Context, datasource.MetadataRequest, *datasource.MetadataResponse) +} + +// Metadata satisfies the datasource.DataSourceWithMetadata interface. +func (d *DataSourceWithMetadata) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + if d.MetadataMethod == nil { + return + } + + d.MetadataMethod(ctx, req, resp) +} diff --git a/internal/testing/testprovider/datasourcewithtypename.go b/internal/testing/testprovider/datasourcewithtypename.go deleted file mode 100644 index 5407b5324..000000000 --- a/internal/testing/testprovider/datasourcewithtypename.go +++ /dev/null @@ -1,27 +0,0 @@ -package testprovider - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-framework/datasource" -) - -var _ datasource.DataSource = &DataSourceWithTypeName{} -var _ datasource.DataSourceWithTypeName = &DataSourceWithTypeName{} - -// Declarative datasource.DataSourceWithTypeName for unit testing. -type DataSourceWithTypeName struct { - *DataSource - - // DataSourceWithTypeName interface methods - TypeNameMethod func(context.Context, datasource.TypeNameRequest, *datasource.TypeNameResponse) -} - -// TypeName satisfies the datasource.DataSourceWithTypeName interface. -func (d *DataSourceWithTypeName) TypeName(ctx context.Context, req datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { - if d.TypeNameMethod == nil { - return - } - - d.TypeNameMethod(ctx, req, resp) -} diff --git a/internal/testing/testprovider/resourcewithgetschema_temp.go b/internal/testing/testprovider/resourcewithgetschema_temp.go index 7e2dc72ca..ac38d7c2b 100644 --- a/internal/testing/testprovider/resourcewithgetschema_temp.go +++ b/internal/testing/testprovider/resourcewithgetschema_temp.go @@ -8,17 +8,17 @@ import ( "github.com/hashicorp/terraform-plugin-framework/tfsdk" ) -// This file contains temporary types until GetSchema and TypeName are required +// This file contains temporary types until GetSchema and Metadata are required // in Resource. -var _ resource.Resource = &ResourceWithConfigValidatorsAndGetSchemaAndTypeName{} -var _ resource.ResourceWithConfigValidators = &ResourceWithConfigValidatorsAndGetSchemaAndTypeName{} -var _ resource.ResourceWithGetSchema = &ResourceWithConfigValidatorsAndGetSchemaAndTypeName{} -var _ resource.ResourceWithTypeName = &ResourceWithConfigValidatorsAndGetSchemaAndTypeName{} +var _ resource.Resource = &ResourceWithConfigValidatorsAndGetSchemaAndMetadata{} +var _ resource.ResourceWithConfigValidators = &ResourceWithConfigValidatorsAndGetSchemaAndMetadata{} +var _ resource.ResourceWithGetSchema = &ResourceWithConfigValidatorsAndGetSchemaAndMetadata{} +var _ resource.ResourceWithMetadata = &ResourceWithConfigValidatorsAndGetSchemaAndMetadata{} // Declarative resource.ResourceWithGetSchema for unit testing. This type is -// temporary until GetSchema and TypeName are required in Resource. -type ResourceWithConfigValidatorsAndGetSchemaAndTypeName struct { +// temporary until GetSchema and Metadata are required in Resource. +type ResourceWithConfigValidatorsAndGetSchemaAndMetadata struct { *Resource // ResourceWithConfigValidators interface methods @@ -27,12 +27,12 @@ type ResourceWithConfigValidatorsAndGetSchemaAndTypeName struct { // ResourceWithGetSchema interface methods GetSchemaMethod func(context.Context) (tfsdk.Schema, diag.Diagnostics) - // ResourceWithTypeName interface methods - TypeNameMethod func(context.Context, resource.TypeNameRequest, *resource.TypeNameResponse) + // ResourceWithMetadata interface methods + MetadataMethod func(context.Context, resource.MetadataRequest, *resource.MetadataResponse) } // ConfigValidators satisfies the resource.ResourceWithConfigValidators interface. -func (r *ResourceWithConfigValidatorsAndGetSchemaAndTypeName) ConfigValidators(ctx context.Context) []resource.ConfigValidator { +func (r *ResourceWithConfigValidatorsAndGetSchemaAndMetadata) ConfigValidators(ctx context.Context) []resource.ConfigValidator { if r.ConfigValidatorsMethod == nil { return nil } @@ -41,7 +41,7 @@ func (r *ResourceWithConfigValidatorsAndGetSchemaAndTypeName) ConfigValidators(c } // GetSchema satisfies the resource.ResourceWithGetSchema interface. -func (r *ResourceWithConfigValidatorsAndGetSchemaAndTypeName) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { +func (r *ResourceWithConfigValidatorsAndGetSchemaAndMetadata) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { if r.GetSchemaMethod == nil { return tfsdk.Schema{}, nil } @@ -49,33 +49,33 @@ func (r *ResourceWithConfigValidatorsAndGetSchemaAndTypeName) GetSchema(ctx cont return r.GetSchemaMethod(ctx) } -// TypeName satisfies the resource.ResourceWithTypeName interface. -func (r *ResourceWithConfigValidatorsAndGetSchemaAndTypeName) TypeName(ctx context.Context, req resource.TypeNameRequest, resp *resource.TypeNameResponse) { - if r.TypeNameMethod == nil { +// Metadata satisfies the resource.ResourceWithMetadata interface. +func (r *ResourceWithConfigValidatorsAndGetSchemaAndMetadata) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + if r.MetadataMethod == nil { return } - r.TypeNameMethod(ctx, req, resp) + r.MetadataMethod(ctx, req, resp) } -var _ resource.Resource = &ResourceWithGetSchemaAndTypeName{} -var _ resource.ResourceWithGetSchema = &ResourceWithGetSchemaAndTypeName{} -var _ resource.ResourceWithTypeName = &ResourceWithGetSchemaAndTypeName{} +var _ resource.Resource = &ResourceWithGetSchemaAndMetadata{} +var _ resource.ResourceWithGetSchema = &ResourceWithGetSchemaAndMetadata{} +var _ resource.ResourceWithMetadata = &ResourceWithGetSchemaAndMetadata{} // Declarative resource.ResourceWithGetSchema for unit testing. This type is -// temporary until GetSchema and TypeName are required in Resource. -type ResourceWithGetSchemaAndTypeName struct { +// temporary until GetSchema and Metadata are required in Resource. +type ResourceWithGetSchemaAndMetadata struct { *Resource // ResourceWithGetSchema interface methods GetSchemaMethod func(context.Context) (tfsdk.Schema, diag.Diagnostics) - // ResourceWithTypeName interface methods - TypeNameMethod func(context.Context, resource.TypeNameRequest, *resource.TypeNameResponse) + // ResourceWithMetadata interface methods + MetadataMethod func(context.Context, resource.MetadataRequest, *resource.MetadataResponse) } // GetSchema satisfies the resource.ResourceWithGetSchema interface. -func (r *ResourceWithGetSchemaAndTypeName) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { +func (r *ResourceWithGetSchemaAndMetadata) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { if r.GetSchemaMethod == nil { return tfsdk.Schema{}, nil } @@ -83,23 +83,23 @@ func (r *ResourceWithGetSchemaAndTypeName) GetSchema(ctx context.Context) (tfsdk return r.GetSchemaMethod(ctx) } -// TypeName satisfies the resource.ResourceWithTypeName interface. -func (r *ResourceWithGetSchemaAndTypeName) TypeName(ctx context.Context, req resource.TypeNameRequest, resp *resource.TypeNameResponse) { - if r.TypeNameMethod == nil { +// Metadata satisfies the resource.ResourceWithMetadata interface. +func (r *ResourceWithGetSchemaAndMetadata) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + if r.MetadataMethod == nil { return } - r.TypeNameMethod(ctx, req, resp) + r.MetadataMethod(ctx, req, resp) } -var _ resource.Resource = &ResourceWithGetSchemaAndImportStateAndTypeName{} -var _ resource.ResourceWithGetSchema = &ResourceWithGetSchemaAndImportStateAndTypeName{} -var _ resource.ResourceWithImportState = &ResourceWithGetSchemaAndImportStateAndTypeName{} -var _ resource.ResourceWithTypeName = &ResourceWithGetSchemaAndImportStateAndTypeName{} +var _ resource.Resource = &ResourceWithGetSchemaAndImportStateAndMetadata{} +var _ resource.ResourceWithGetSchema = &ResourceWithGetSchemaAndImportStateAndMetadata{} +var _ resource.ResourceWithImportState = &ResourceWithGetSchemaAndImportStateAndMetadata{} +var _ resource.ResourceWithMetadata = &ResourceWithGetSchemaAndImportStateAndMetadata{} // Declarative resource.ResourceWithGetSchema for unit testing. This type is -// temporary until GetSchema and TypeName are required in Resource. -type ResourceWithGetSchemaAndImportStateAndTypeName struct { +// temporary until GetSchema and Metadata are required in Resource. +type ResourceWithGetSchemaAndImportStateAndMetadata struct { *Resource // ResourceWithGetSchema interface methods @@ -108,12 +108,12 @@ type ResourceWithGetSchemaAndImportStateAndTypeName struct { // ResourceWithImportState interface methods ImportStateMethod func(context.Context, resource.ImportStateRequest, *resource.ImportStateResponse) - // ResourceWithTypeName interface methods - TypeNameMethod func(context.Context, resource.TypeNameRequest, *resource.TypeNameResponse) + // ResourceWithMetadata interface methods + MetadataMethod func(context.Context, resource.MetadataRequest, *resource.MetadataResponse) } // GetSchema satisfies the resource.ResourceWithGetSchema interface. -func (r *ResourceWithGetSchemaAndImportStateAndTypeName) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { +func (r *ResourceWithGetSchemaAndImportStateAndMetadata) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { if r.GetSchemaMethod == nil { return tfsdk.Schema{}, nil } @@ -122,7 +122,7 @@ func (r *ResourceWithGetSchemaAndImportStateAndTypeName) GetSchema(ctx context.C } // ImportState satisfies the resource.ResourceWithImportState interface. -func (r *ResourceWithGetSchemaAndImportStateAndTypeName) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { +func (r *ResourceWithGetSchemaAndImportStateAndMetadata) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { if r.ImportStateMethod == nil { return } @@ -130,23 +130,23 @@ func (r *ResourceWithGetSchemaAndImportStateAndTypeName) ImportState(ctx context r.ImportStateMethod(ctx, req, resp) } -// TypeName satisfies the resource.ResourceWithTypeName interface. -func (r *ResourceWithGetSchemaAndImportStateAndTypeName) TypeName(ctx context.Context, req resource.TypeNameRequest, resp *resource.TypeNameResponse) { - if r.TypeNameMethod == nil { +// Metadata satisfies the resource.ResourceWithMetadata interface. +func (r *ResourceWithGetSchemaAndImportStateAndMetadata) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + if r.MetadataMethod == nil { return } - r.TypeNameMethod(ctx, req, resp) + r.MetadataMethod(ctx, req, resp) } -var _ resource.Resource = &ResourceWithGetSchemaAndModifyPlanAndTypeName{} -var _ resource.ResourceWithGetSchema = &ResourceWithGetSchemaAndModifyPlanAndTypeName{} -var _ resource.ResourceWithModifyPlan = &ResourceWithGetSchemaAndModifyPlanAndTypeName{} -var _ resource.ResourceWithTypeName = &ResourceWithGetSchemaAndModifyPlanAndTypeName{} +var _ resource.Resource = &ResourceWithGetSchemaAndModifyPlanAndMetadata{} +var _ resource.ResourceWithGetSchema = &ResourceWithGetSchemaAndModifyPlanAndMetadata{} +var _ resource.ResourceWithModifyPlan = &ResourceWithGetSchemaAndModifyPlanAndMetadata{} +var _ resource.ResourceWithMetadata = &ResourceWithGetSchemaAndModifyPlanAndMetadata{} // Declarative resource.ResourceWithGetSchema for unit testing. This type is -// temporary until GetSchema and TypeName are required in Resource. -type ResourceWithGetSchemaAndModifyPlanAndTypeName struct { +// temporary until GetSchema and Metadata are required in Resource. +type ResourceWithGetSchemaAndModifyPlanAndMetadata struct { *Resource // ResourceWithGetSchema interface methods @@ -155,12 +155,12 @@ type ResourceWithGetSchemaAndModifyPlanAndTypeName struct { // ResourceWithModifyPlan interface methods ModifyPlanMethod func(context.Context, resource.ModifyPlanRequest, *resource.ModifyPlanResponse) - // ResourceWithTypeName interface methods - TypeNameMethod func(context.Context, resource.TypeNameRequest, *resource.TypeNameResponse) + // ResourceWithMetadata interface methods + MetadataMethod func(context.Context, resource.MetadataRequest, *resource.MetadataResponse) } // GetSchema satisfies the resource.ResourceWithGetSchema interface. -func (r *ResourceWithGetSchemaAndModifyPlanAndTypeName) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { +func (r *ResourceWithGetSchemaAndModifyPlanAndMetadata) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { if r.GetSchemaMethod == nil { return tfsdk.Schema{}, nil } @@ -169,7 +169,7 @@ func (r *ResourceWithGetSchemaAndModifyPlanAndTypeName) GetSchema(ctx context.Co } // ModifyPlan satisfies the resource.ResourceWithModifyPlan interface. -func (r *ResourceWithGetSchemaAndModifyPlanAndTypeName) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { +func (r *ResourceWithGetSchemaAndModifyPlanAndMetadata) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { if r.ModifyPlanMethod == nil { return } @@ -177,37 +177,37 @@ func (r *ResourceWithGetSchemaAndModifyPlanAndTypeName) ModifyPlan(ctx context.C r.ModifyPlanMethod(ctx, req, resp) } -// TypeName satisfies the resource.ResourceWithTypeName interface. -func (r *ResourceWithGetSchemaAndModifyPlanAndTypeName) TypeName(ctx context.Context, req resource.TypeNameRequest, resp *resource.TypeNameResponse) { - if r.TypeNameMethod == nil { +// Metadata satisfies the resource.ResourceWithMetadata interface. +func (r *ResourceWithGetSchemaAndModifyPlanAndMetadata) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + if r.MetadataMethod == nil { return } - r.TypeNameMethod(ctx, req, resp) + r.MetadataMethod(ctx, req, resp) } -var _ resource.Resource = &ResourceWithGetSchemaAndTypeNameAndUpgradeState{} -var _ resource.ResourceWithGetSchema = &ResourceWithGetSchemaAndTypeNameAndUpgradeState{} -var _ resource.ResourceWithTypeName = &ResourceWithGetSchemaAndTypeNameAndUpgradeState{} -var _ resource.ResourceWithUpgradeState = &ResourceWithGetSchemaAndTypeNameAndUpgradeState{} +var _ resource.Resource = &ResourceWithGetSchemaAndMetadataAndUpgradeState{} +var _ resource.ResourceWithGetSchema = &ResourceWithGetSchemaAndMetadataAndUpgradeState{} +var _ resource.ResourceWithMetadata = &ResourceWithGetSchemaAndMetadataAndUpgradeState{} +var _ resource.ResourceWithUpgradeState = &ResourceWithGetSchemaAndMetadataAndUpgradeState{} // Declarative resource.ResourceWithGetSchema for unit testing. This type is -// temporary until GetSchema and TypeName are required in Resource. -type ResourceWithGetSchemaAndTypeNameAndUpgradeState struct { +// temporary until GetSchema and Metadata are required in Resource. +type ResourceWithGetSchemaAndMetadataAndUpgradeState struct { *Resource // ResourceWithGetSchema interface methods GetSchemaMethod func(context.Context) (tfsdk.Schema, diag.Diagnostics) - // ResourceWithTypeName interface methods - TypeNameMethod func(context.Context, resource.TypeNameRequest, *resource.TypeNameResponse) + // ResourceWithMetadata interface methods + MetadataMethod func(context.Context, resource.MetadataRequest, *resource.MetadataResponse) // ResourceWithUpgradeState interface methods UpgradeStateMethod func(context.Context) map[int64]resource.StateUpgrader } // GetSchema satisfies the resource.ResourceWithGetSchema interface. -func (r *ResourceWithGetSchemaAndTypeNameAndUpgradeState) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { +func (r *ResourceWithGetSchemaAndMetadataAndUpgradeState) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { if r.GetSchemaMethod == nil { return tfsdk.Schema{}, nil } @@ -215,17 +215,17 @@ func (r *ResourceWithGetSchemaAndTypeNameAndUpgradeState) GetSchema(ctx context. return r.GetSchemaMethod(ctx) } -// TypeName satisfies the resource.ResourceWithTypeName interface. -func (r *ResourceWithGetSchemaAndTypeNameAndUpgradeState) TypeName(ctx context.Context, req resource.TypeNameRequest, resp *resource.TypeNameResponse) { - if r.TypeNameMethod == nil { +// Metadata satisfies the resource.ResourceWithMetadata interface. +func (r *ResourceWithGetSchemaAndMetadataAndUpgradeState) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + if r.MetadataMethod == nil { return } - r.TypeNameMethod(ctx, req, resp) + r.MetadataMethod(ctx, req, resp) } // UpgradeState satisfies the resource.ResourceWithUpgradeState interface. -func (r *ResourceWithGetSchemaAndTypeNameAndUpgradeState) UpgradeState(ctx context.Context) map[int64]resource.StateUpgrader { +func (r *ResourceWithGetSchemaAndMetadataAndUpgradeState) UpgradeState(ctx context.Context) map[int64]resource.StateUpgrader { if r.UpgradeStateMethod == nil { return nil } @@ -233,28 +233,28 @@ func (r *ResourceWithGetSchemaAndTypeNameAndUpgradeState) UpgradeState(ctx conte return r.UpgradeStateMethod(ctx) } -var _ resource.Resource = &ResourceWithGetSchemaAndTypeNameAndValidateConfig{} -var _ resource.ResourceWithGetSchema = &ResourceWithGetSchemaAndTypeNameAndValidateConfig{} -var _ resource.ResourceWithTypeName = &ResourceWithGetSchemaAndTypeNameAndValidateConfig{} -var _ resource.ResourceWithValidateConfig = &ResourceWithGetSchemaAndTypeNameAndValidateConfig{} +var _ resource.Resource = &ResourceWithGetSchemaAndMetadataAndValidateConfig{} +var _ resource.ResourceWithGetSchema = &ResourceWithGetSchemaAndMetadataAndValidateConfig{} +var _ resource.ResourceWithMetadata = &ResourceWithGetSchemaAndMetadataAndValidateConfig{} +var _ resource.ResourceWithValidateConfig = &ResourceWithGetSchemaAndMetadataAndValidateConfig{} // Declarative resource.ResourceWithGetSchema for unit testing. This type is -// temporary until GetSchema and TypeName are required in Resource. -type ResourceWithGetSchemaAndTypeNameAndValidateConfig struct { +// temporary until GetSchema and Metadata are required in Resource. +type ResourceWithGetSchemaAndMetadataAndValidateConfig struct { *Resource // ResourceWithGetSchema interface methods GetSchemaMethod func(context.Context) (tfsdk.Schema, diag.Diagnostics) - // ResourceWithTypeName interface methods - TypeNameMethod func(context.Context, resource.TypeNameRequest, *resource.TypeNameResponse) + // ResourceWithMetadata interface methods + MetadataMethod func(context.Context, resource.MetadataRequest, *resource.MetadataResponse) // ResourceWithValidateConfig interface methods ValidateConfigMethod func(context.Context, resource.ValidateConfigRequest, *resource.ValidateConfigResponse) } // GetSchema satisfies the resource.ResourceWithGetSchema interface. -func (r *ResourceWithGetSchemaAndTypeNameAndValidateConfig) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { +func (r *ResourceWithGetSchemaAndMetadataAndValidateConfig) GetSchema(ctx context.Context) (tfsdk.Schema, diag.Diagnostics) { if r.GetSchemaMethod == nil { return tfsdk.Schema{}, nil } @@ -262,17 +262,17 @@ func (r *ResourceWithGetSchemaAndTypeNameAndValidateConfig) GetSchema(ctx contex return r.GetSchemaMethod(ctx) } -// TypeName satisfies the resource.ResourceWithTypeName interface. -func (r *ResourceWithGetSchemaAndTypeNameAndValidateConfig) TypeName(ctx context.Context, req resource.TypeNameRequest, resp *resource.TypeNameResponse) { - if r.TypeNameMethod == nil { +// Metadata satisfies the resource.ResourceWithMetadata interface. +func (r *ResourceWithGetSchemaAndMetadataAndValidateConfig) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + if r.MetadataMethod == nil { return } - r.TypeNameMethod(ctx, req, resp) + r.MetadataMethod(ctx, req, resp) } // ValidateConfig satisfies the resource.ResourceWithValidateConfig interface. -func (r *ResourceWithGetSchemaAndTypeNameAndValidateConfig) ValidateConfig(ctx context.Context, req resource.ValidateConfigRequest, resp *resource.ValidateConfigResponse) { +func (r *ResourceWithGetSchemaAndMetadataAndValidateConfig) ValidateConfig(ctx context.Context, req resource.ValidateConfigRequest, resp *resource.ValidateConfigResponse) { if r.ValidateConfigMethod == nil { return } diff --git a/internal/testing/testprovider/resourcewithmetadata.go b/internal/testing/testprovider/resourcewithmetadata.go new file mode 100644 index 000000000..83dcd5a3a --- /dev/null +++ b/internal/testing/testprovider/resourcewithmetadata.go @@ -0,0 +1,27 @@ +package testprovider + +import ( + "context" + + "github.com/hashicorp/terraform-plugin-framework/resource" +) + +var _ resource.Resource = &ResourceWithMetadata{} +var _ resource.ResourceWithMetadata = &ResourceWithMetadata{} + +// Declarative resource.ResourceWithMetadata for unit testing. +type ResourceWithMetadata struct { + *Resource + + // ResourceWithMetadata interface methods + MetadataMethod func(context.Context, resource.MetadataRequest, *resource.MetadataResponse) +} + +// Metadata satisfies the resource.ResourceWithMetadata interface. +func (r *ResourceWithMetadata) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + if r.MetadataMethod == nil { + return + } + + r.MetadataMethod(ctx, req, resp) +} diff --git a/internal/testing/testprovider/resourcewithtypename.go b/internal/testing/testprovider/resourcewithtypename.go deleted file mode 100644 index b38f33147..000000000 --- a/internal/testing/testprovider/resourcewithtypename.go +++ /dev/null @@ -1,27 +0,0 @@ -package testprovider - -import ( - "context" - - "github.com/hashicorp/terraform-plugin-framework/resource" -) - -var _ resource.Resource = &ResourceWithTypeName{} -var _ resource.ResourceWithTypeName = &ResourceWithTypeName{} - -// Declarative resource.ResourceWithTypeName for unit testing. -type ResourceWithTypeName struct { - *Resource - - // ResourceWithTypeName interface methods - TypeNameMethod func(context.Context, resource.TypeNameRequest, *resource.TypeNameResponse) -} - -// TypeName satisfies the resource.ResourceWithTypeName interface. -func (r *ResourceWithTypeName) TypeName(ctx context.Context, req resource.TypeNameRequest, resp *resource.TypeNameResponse) { - if r.TypeNameMethod == nil { - return - } - - r.TypeNameMethod(ctx, req, resp) -} diff --git a/provider/data_source_type.go b/provider/data_source_type.go index 7ea0d51c7..9ee76f986 100644 --- a/provider/data_source_type.go +++ b/provider/data_source_type.go @@ -13,7 +13,7 @@ import ( // return an instance of it in the map returned by Provider.GetDataSources. // // Deprecated: Migrate to datasource.DataSource implementation Configure, -// GetSchema, and TypeName methods. Migrate the provider.Provider +// GetSchema, and Metadata methods. Migrate the provider.Provider // implementation from the GetDataSources method to the DataSources method. type DataSourceType interface { // GetSchema returns the schema for this data source. diff --git a/provider/provider.go b/provider/provider.go index 3d6e1bbf6..11d7f1a64 100644 --- a/provider/provider.go +++ b/provider/provider.go @@ -59,7 +59,7 @@ type ProviderWithDataSources interface { // implementation. // // The data source type name is determined by the DataSource implementing - // the TypeName method. All data sources must have unique names. + // the Metadata method. All data sources must have unique names. DataSources(context.Context) []func() datasource.DataSource } @@ -110,8 +110,8 @@ type ProviderWithGetResources interface { // metadata, such as version. // // Implementing this method will populate the -// [datasource.TypeNameRequest.ProviderTypeName] and -// [resource.TypeNameRequest.ProviderTypeName] fields automatically. +// [datasource.MetadataRequest.ProviderTypeName] and +// [resource.MetadataRequest.ProviderTypeName] fields automatically. type ProviderWithMetadata interface { Provider @@ -140,7 +140,7 @@ type ProviderWithResources interface { // implementation. // // The resource type name is determined by the Resource implementing - // the TypeName method. All resources must have unique names. + // the Metadata method. All resources must have unique names. Resources(context.Context) []func() resource.Resource } diff --git a/provider/resource_type.go b/provider/resource_type.go index 57880868c..93c61e5d0 100644 --- a/provider/resource_type.go +++ b/provider/resource_type.go @@ -13,7 +13,7 @@ import ( // instance of it in the map returned by Provider.GetResources. // // Deprecated: Migrate to resource.Resource implementation Configure, -// GetSchema, and TypeName methods. Migrate the provider.Provider +// GetSchema, and Metadata methods. Migrate the provider.Provider // implementation from the GetResources method to the Resources method. type ResourceType interface { // GetSchema returns the schema for this resource. diff --git a/resource/type_name.go b/resource/metadata.go similarity index 58% rename from resource/type_name.go rename to resource/metadata.go index 0acd007d7..683292113 100644 --- a/resource/type_name.go +++ b/resource/metadata.go @@ -1,9 +1,9 @@ package resource -// TypeNameRequest represents a request for the Resource to return its type -// name. An instance of this request struct is supplied as an argument to the -// Resource type TypeName method. -type TypeNameRequest struct { +// MetadataRequest represents a request for the Resource to return metadata, +// such as its type name. An instance of this request struct is supplied as +// an argument to the Resource type Metadata method. +type MetadataRequest struct { // ProviderTypeName is the string returned from // [provider.MetadataResponse.TypeName], if the Provider type implements // the Metadata method. This string should prefix the Resource type name @@ -11,10 +11,10 @@ type TypeNameRequest struct { ProviderTypeName string } -// TypeNameResponse represents a response to a TypeNameRequest. An +// MetadataResponse represents a response to a MetadataRequest. An // instance of this response struct is supplied as an argument to the -// Resource type TypeName method. -type TypeNameResponse struct { +// Resource type Metadata method. +type MetadataResponse struct { // TypeName should be the full resource type, including the provider // type prefix and an underscore. For example, examplecloud_thing. TypeName string diff --git a/resource/resource.go b/resource/resource.go index b30b53fcb..c8aea6ddd 100644 --- a/resource/resource.go +++ b/resource/resource.go @@ -130,18 +130,18 @@ type ResourceWithModifyPlan interface { ModifyPlan(context.Context, ModifyPlanRequest, *ModifyPlanResponse) } -// ResourceWithTypeName is an interface type that extends Resource to -// return its resource type name. For example, if the provider is named -// examplecloud and the resource manages a thing, this should return -// examplecloud_thing. +// ResourceWithMetadata is an interface type that extends Resource to +// return metadata, such as its resource type name. For example, if the +// provider is named examplecloud and the resource manages a thing, this +// should return examplecloud_thing. // // This method will be required in the Resource interface a future release. -type ResourceWithTypeName interface { +type ResourceWithMetadata interface { Resource - // TypeName should return the full name of the resource, such as + // Metadata should return the full name of the resource, such as // examplecloud_thing. - TypeName(context.Context, TypeNameRequest, *TypeNameResponse) + Metadata(context.Context, MetadataRequest, *MetadataResponse) } // Optional interface on top of Resource that enables provider control over diff --git a/website/docs/plugin/framework/data-sources/index.mdx b/website/docs/plugin/framework/data-sources/index.mdx index 2c057ab89..ea3a88bc7 100644 --- a/website/docs/plugin/framework/data-sources/index.mdx +++ b/website/docs/plugin/framework/data-sources/index.mdx @@ -31,7 +31,7 @@ type ThingDataSourceModel struct { ID types.String `tfsdk:"id"` } -func (d *ThingDataSource) TypeName(ctx context.Context, req datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { +func (d *ThingDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "examplecloud_thing" } @@ -65,20 +65,20 @@ func (d *ThingDataSource) Read(ctx context.Context, req datasource.ReadRequest, } ``` -### TypeName Method +### Metadata Method -The [`datasource.DataSourceWithTypeName` interface `TypeName` method](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/datasource#DataSourceWithTypeName.TypeName) defines the data source name as it would appear in Terraform configurations. This name should include the provider type prefix, an underscore, then the data source specific name. For example, a provider named `examplecloud` and a data source that reads "thing" resources would be named `examplecloud_thing`. Ensure the [Add Data Source To Provider](#add-data-source-to-provider) documentation is followed so the data source becomes part of the provider implementation, and therefore available to practitioners. +The [`datasource.DataSourceWithMetadata` interface `Metadata` method](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/datasource#DataSourceWithMetadata.Metadata) defines the data source name as it would appear in Terraform configurations. This name should include the provider type prefix, an underscore, then the data source specific name. For example, a provider named `examplecloud` and a data source that reads "thing" resources would be named `examplecloud_thing`. Ensure the [Add Data Source To Provider](#add-data-source-to-provider) documentation is followed so the data source becomes part of the provider implementation, and therefore available to practitioners. In this example, the data source name in an `examplecloud` provider that reads "thing" resources is hardcoded to `examplecloud_thing`: ```go // With the datasource.DataSource implementation -func (d *ThingDataSource) TypeName(ctx context.Context, req datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { +func (d *ThingDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = "examplecloud_thing" } ``` -To simplify data source implementations, the [`provider.MetadataResponse.TypeName` field](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/provider#MetadataResponse.TypeName) from the [`provider.ProviderWithMetadata` interface `Metadata` method](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/provider#ProviderWithMetadata.Metadata) can set the provider name so it is available in the [`datasource.TypeNameRequest.ProviderTypeName` field](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/datasource#TypeNameRequest.ProviderTypeName). +To simplify data source implementations, the [`provider.MetadataResponse.TypeName` field](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/provider#MetadataResponse.TypeName) from the [`provider.ProviderWithMetadata` interface `Metadata` method](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/provider#ProviderWithMetadata.Metadata) can set the provider name so it is available in the [`datasource.MetadataRequest.ProviderTypeName` field](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/datasource#MetadataRequest.ProviderTypeName). In this example, the provider defines the `examplecloud` name for itself, and the data source is named `examplecloud_thing`: @@ -89,7 +89,7 @@ func (p *ExampleCloudProvider) Metadata(ctx context.Context, req provider.Metada } // With the datasource.DataSource implementation -func (d *ThingDataSource) TypeName(ctx context.Context, req datasource.TypeNameRequest, resp *datasource.TypeNameResponse) { +func (d *ThingDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { resp.TypeName = req.ProviderTypeName + "_thing" } ``` diff --git a/website/docs/plugin/framework/resources/index.mdx b/website/docs/plugin/framework/resources/index.mdx index 07922f7bc..75e6b9a14 100644 --- a/website/docs/plugin/framework/resources/index.mdx +++ b/website/docs/plugin/framework/resources/index.mdx @@ -39,7 +39,7 @@ type ThingResourceModel struct { ID types.String `tfsdk:"id"` } -func (r *ThingResource) TypeName(ctx context.Context, req resource.TypeNameRequest, resp *resource.TypeNameResponse) { +func (r *ThingResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "examplecloud_thing" } @@ -109,20 +109,20 @@ func (r *ThingResource) Read(ctx context.Context, req resource.ReadRequest, resp } ``` -### TypeName Method +### Metadata Method -The [`resource.ResourceWithTypeName` interface `TypeName` method](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/resource#ResourceWithTypeName.TypeName) defines the resource name as it would appear in Terraform configurations. This name should include the provider type prefix, an underscore, then the resource specific name. For example, a provider named `examplecloud` and a resource that reads "thing" resources would be named `examplecloud_thing`. Ensure the [Add Data Source To Provider](#add-data-source-to-provider) documentation is followed so the resource becomes part of the provider implementation, and therefore available to practitioners. +The [`resource.ResourceWithMetadata` interface `Metadata` method](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/resource#ResourceWithMetadata.Metadata) defines the resource name as it would appear in Terraform configurations. This name should include the provider type prefix, an underscore, then the resource specific name. For example, a provider named `examplecloud` and a resource that reads "thing" resources would be named `examplecloud_thing`. Ensure the [Add Data Source To Provider](#add-data-source-to-provider) documentation is followed so the resource becomes part of the provider implementation, and therefore available to practitioners. In this example, the resource name in an `examplecloud` provider that reads "thing" resources is hardcoded to `examplecloud_thing`: ```go // With the resource.Resource implementation -func (r *ThingResource) TypeName(ctx context.Context, req resource.TypeNameRequest, resp *resource.TypeNameResponse) { +func (r *ThingResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = "examplecloud_thing" } ``` -To simplify resource implementations, the [`provider.MetadataResponse.TypeName` field](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/provider#MetadataResponse.TypeName) from the [`provider.ProviderWithMetadata` interface `Metadata` method](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/provider#ProviderWithMetadata.Metadata) can set the provider name so it is available in the [`resource.TypeNameRequest.ProviderTypeName` field](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/resource#TypeNameRequest.ProviderTypeName). +To simplify resource implementations, the [`provider.MetadataResponse.TypeName` field](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/provider#MetadataResponse.TypeName) from the [`provider.ProviderWithMetadata` interface `Metadata` method](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/provider#ProviderWithMetadata.Metadata) can set the provider name so it is available in the [`resource.MetadataRequest.ProviderTypeName` field](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/resource#MetadataRequest.ProviderTypeName). In this example, the provider defines the `examplecloud` name for itself, and the data source is named `examplecloud_thing`: @@ -133,7 +133,7 @@ func (p *ExampleCloudProvider) Metadata(ctx context.Context, req provider.Metada } // With the resource.Resource implementation -func (d *ThingDataSource) TypeName(ctx context.Context, req resource.TypeNameRequest, resp *resource.TypeNameResponse) { +func (d *ThingDataSource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { resp.TypeName = req.ProviderTypeName + "_thing" } ```