diff --git a/.changelog/pending.txt b/.changelog/pending.txt new file mode 100644 index 000000000..8fe5c6369 --- /dev/null +++ b/.changelog/pending.txt @@ -0,0 +1,3 @@ +```release-note:breaking-change +tfsdk: The `ResourceImportStateNotImplemented()` function has been removed. Remove the `Resource` type `ImportState` method instead for resources that should not support import. +``` diff --git a/internal/proto6server/serve_import.go b/internal/proto6server/serve_import.go index 03aac0895..ad3241f7e 100644 --- a/internal/proto6server/serve_import.go +++ b/internal/proto6server/serve_import.go @@ -135,7 +135,7 @@ func (s *Server) importResourceState(ctx context.Context, req *tfprotov6.ImportR resp.Diagnostics.AddError( "Missing Resource Import State", "An unexpected error was encountered when importing the resource. This is always a problem with the provider. Please give the following information to the provider developer:\n\n"+ - "Resource ImportState method returned no State in response. If import is intentionally not supported, call the ResourceImportStateNotImplemented() function or return an error.", + "Resource ImportState method returned no State in response. If import is intentionally not supported, remove the Resource type ImportState method or return an error.", ) return } diff --git a/internal/proto6server/serve_import_test.go b/internal/proto6server/serve_import_test.go index 60d2bf6fe..0cdfe106d 100644 --- a/internal/proto6server/serve_import_test.go +++ b/internal/proto6server/serve_import_test.go @@ -96,27 +96,6 @@ func TestServerImportResourceState(t *testing.T) { }, }, }, - "ResourceImportStateNotImplemented": { - req: &tfprotov6.ImportResourceStateRequest{ - ID: "test", - TypeName: "test_import_state", - }, - - impl: func(ctx context.Context, req tfsdk.ImportResourceStateRequest, resp *tfsdk.ImportResourceStateResponse) { - //nolint:staticcheck // This will be removed before the next minor release. - tfsdk.ResourceImportStateNotImplemented(ctx, "", resp) - }, - - resp: &tfprotov6.ImportResourceStateResponse{ - Diagnostics: []*tfprotov6.Diagnostic{ - { - Summary: "Resource Import Not Implemented", - Severity: tfprotov6.DiagnosticSeverityError, - Detail: "This resource does not support import. Please contact the provider developer for additional information.", - }, - }, - }, - }, "imported_resource_conversion_error": { req: &tfprotov6.ImportResourceStateRequest{ ID: "test", @@ -153,7 +132,7 @@ func TestServerImportResourceState(t *testing.T) { Summary: "Missing Resource Import State", Severity: tfprotov6.DiagnosticSeverityError, Detail: "An unexpected error was encountered when importing the resource. This is always a problem with the provider. Please give the following information to the provider developer:\n\n" + - "Resource ImportState method returned no State in response. If import is intentionally not supported, call the ResourceImportStateNotImplemented() function or return an error.", + "Resource ImportState method returned no State in response. If import is intentionally not supported, remove the Resource type ImportState method or return an error.", }, }, }, diff --git a/internal/proto6server/serve_resource_upgrade_state_not_implemented_test.go b/internal/proto6server/serve_resource_upgrade_state_not_implemented_test.go index f845ebe6d..f413d8669 100644 --- a/internal/proto6server/serve_resource_upgrade_state_not_implemented_test.go +++ b/internal/proto6server/serve_resource_upgrade_state_not_implemented_test.go @@ -86,7 +86,3 @@ func (r testServeResourceUpgradeStateNotImplemented) Update(ctx context.Context, func (r testServeResourceUpgradeStateNotImplemented) Delete(ctx context.Context, req tfsdk.DeleteResourceRequest, resp *tfsdk.DeleteResourceResponse) { // Intentionally blank. Not expected to be called during testing. } -func (r testServeResourceUpgradeStateNotImplemented) ImportState(ctx context.Context, req tfsdk.ImportResourceStateRequest, resp *tfsdk.ImportResourceStateResponse) { - //nolint:staticcheck // This will be removed before the next minor release. - tfsdk.ResourceImportStateNotImplemented(ctx, "intentionally not implemented", resp) -} diff --git a/tfsdk/resource_import.go b/tfsdk/resource_import.go index f22018910..93e22a5c7 100644 --- a/tfsdk/resource_import.go +++ b/tfsdk/resource_import.go @@ -20,23 +20,6 @@ type ResourceWithImportState interface { ImportState(context.Context, ImportResourceStateRequest, *ImportResourceStateResponse) } -// ResourceImportStateNotImplemented is a helper function to return an error -// diagnostic about the resource not supporting import. The details defaults -// to a generic message to contact the provider developer, but can be -// customized to provide specific information or recommendations. -// -// Deprecated: Remove the ImportState method from the Resource instead. -func ResourceImportStateNotImplemented(ctx context.Context, details string, resp *ImportResourceStateResponse) { - if details == "" { - details = "This resource does not support import. Please contact the provider developer for additional information." - } - - resp.Diagnostics.AddError( - "Resource Import Not Implemented", - details, - ) -} - // ResourceImportStatePassthroughID is a helper function to set the import // identifier to a given state attribute path. The attribute must accept a // string value.