Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/312.txt
Original file line number Diff line number Diff line change
@@ -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.
```
2 changes: 1 addition & 1 deletion internal/proto6server/serve_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
23 changes: 1 addition & 22 deletions internal/proto6server/serve_import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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.",
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
17 changes: 0 additions & 17 deletions tfsdk/resource_import.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down