From ba1098a5813d88ab817ba1c8d70a6d1b58793660 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ch=C3=A1bek?= Date: Tue, 17 Sep 2024 22:39:38 +0200 Subject: [PATCH] add missing capability MoveResourceState (#1038) * add missing capability MoveResourceState --------- --- .changes/unreleased/BUG FIXES-20240917-163716.yaml | 6 ++++++ internal/proto5server/server_getmetadata_test.go | 9 +++++++++ .../proto5server/server_getproviderschema_test.go | 11 +++++++++++ internal/proto6server/server_getmetadata_test.go | 9 +++++++++ .../proto6server/server_getproviderschema_test.go | 11 +++++++++++ internal/toproto5/server_capabilities.go | 1 + internal/toproto5/server_capabilities_test.go | 8 ++++++++ internal/toproto6/server_capabilities.go | 1 + internal/toproto6/server_capabilities_test.go | 8 ++++++++ 9 files changed, 64 insertions(+) create mode 100644 .changes/unreleased/BUG FIXES-20240917-163716.yaml diff --git a/.changes/unreleased/BUG FIXES-20240917-163716.yaml b/.changes/unreleased/BUG FIXES-20240917-163716.yaml new file mode 100644 index 000000000..b9abe4496 --- /dev/null +++ b/.changes/unreleased/BUG FIXES-20240917-163716.yaml @@ -0,0 +1,6 @@ +kind: BUG FIXES +body: 'providerserver: Fixed bug that prevented `moved` operation support between + resource types for framework-only providers.' +time: 2024-09-17T16:37:16.161402-04:00 +custom: + Issue: "1039" diff --git a/internal/proto5server/server_getmetadata_test.go b/internal/proto5server/server_getmetadata_test.go index decc62739..fffb8146f 100644 --- a/internal/proto5server/server_getmetadata_test.go +++ b/internal/proto5server/server_getmetadata_test.go @@ -65,6 +65,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov5.ResourceMetadata{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -110,6 +111,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov5.ResourceMetadata{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -147,6 +149,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov5.ResourceMetadata{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -190,6 +193,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov5.ResourceMetadata{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -235,6 +239,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov5.ResourceMetadata{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -272,6 +277,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov5.ResourceMetadata{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -315,6 +321,7 @@ func TestServerGetMetadata(t *testing.T) { }, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -360,6 +367,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov5.ResourceMetadata{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -397,6 +405,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov5.ResourceMetadata{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, diff --git a/internal/proto5server/server_getproviderschema_test.go b/internal/proto5server/server_getproviderschema_test.go index 29b33024a..59c34a40d 100644 --- a/internal/proto5server/server_getproviderschema_test.go +++ b/internal/proto5server/server_getproviderschema_test.go @@ -110,6 +110,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -176,6 +177,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -216,6 +218,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -278,6 +281,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -336,6 +340,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -376,6 +381,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -414,6 +420,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -456,6 +463,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -536,6 +544,7 @@ func TestServerGetProviderSchema(t *testing.T) { }, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -602,6 +611,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -642,6 +652,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov5.Schema{}, ServerCapabilities: &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, diff --git a/internal/proto6server/server_getmetadata_test.go b/internal/proto6server/server_getmetadata_test.go index 35dc1a4c7..1029dd232 100644 --- a/internal/proto6server/server_getmetadata_test.go +++ b/internal/proto6server/server_getmetadata_test.go @@ -65,6 +65,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov6.ResourceMetadata{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -110,6 +111,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov6.ResourceMetadata{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -147,6 +149,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov6.ResourceMetadata{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -190,6 +193,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov6.ResourceMetadata{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -235,6 +239,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov6.ResourceMetadata{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -272,6 +277,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov6.ResourceMetadata{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -315,6 +321,7 @@ func TestServerGetMetadata(t *testing.T) { }, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -360,6 +367,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov6.ResourceMetadata{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -397,6 +405,7 @@ func TestServerGetMetadata(t *testing.T) { Resources: []tfprotov6.ResourceMetadata{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, diff --git a/internal/proto6server/server_getproviderschema_test.go b/internal/proto6server/server_getproviderschema_test.go index fc5958f25..2a0fd9753 100644 --- a/internal/proto6server/server_getproviderschema_test.go +++ b/internal/proto6server/server_getproviderschema_test.go @@ -110,6 +110,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -176,6 +177,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -216,6 +218,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -278,6 +281,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -336,6 +340,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -376,6 +381,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -414,6 +420,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -456,6 +463,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -536,6 +544,7 @@ func TestServerGetProviderSchema(t *testing.T) { }, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -602,6 +611,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, @@ -642,6 +652,7 @@ func TestServerGetProviderSchema(t *testing.T) { ResourceSchemas: map[string]*tfprotov6.Schema{}, ServerCapabilities: &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: true, + MoveResourceState: true, PlanDestroy: true, }, }, diff --git a/internal/toproto5/server_capabilities.go b/internal/toproto5/server_capabilities.go index fd968906d..2ed77acbe 100644 --- a/internal/toproto5/server_capabilities.go +++ b/internal/toproto5/server_capabilities.go @@ -19,6 +19,7 @@ func ServerCapabilities(ctx context.Context, fw *fwserver.ServerCapabilities) *t return &tfprotov5.ServerCapabilities{ GetProviderSchemaOptional: fw.GetProviderSchemaOptional, + MoveResourceState: fw.MoveResourceState, PlanDestroy: fw.PlanDestroy, } } diff --git a/internal/toproto5/server_capabilities_test.go b/internal/toproto5/server_capabilities_test.go index 772909e56..95eac4af6 100644 --- a/internal/toproto5/server_capabilities_test.go +++ b/internal/toproto5/server_capabilities_test.go @@ -32,6 +32,14 @@ func TestServerCapabilities(t *testing.T) { GetProviderSchemaOptional: true, }, }, + "MoveResourceState": { + fw: &fwserver.ServerCapabilities{ + MoveResourceState: true, + }, + expected: &tfprotov5.ServerCapabilities{ + MoveResourceState: true, + }, + }, "PlanDestroy": { fw: &fwserver.ServerCapabilities{ PlanDestroy: true, diff --git a/internal/toproto6/server_capabilities.go b/internal/toproto6/server_capabilities.go index ef46cbf16..26c24f7c6 100644 --- a/internal/toproto6/server_capabilities.go +++ b/internal/toproto6/server_capabilities.go @@ -19,6 +19,7 @@ func ServerCapabilities(ctx context.Context, fw *fwserver.ServerCapabilities) *t return &tfprotov6.ServerCapabilities{ GetProviderSchemaOptional: fw.GetProviderSchemaOptional, + MoveResourceState: fw.MoveResourceState, PlanDestroy: fw.PlanDestroy, } } diff --git a/internal/toproto6/server_capabilities_test.go b/internal/toproto6/server_capabilities_test.go index f3a91ac03..a9e6955fe 100644 --- a/internal/toproto6/server_capabilities_test.go +++ b/internal/toproto6/server_capabilities_test.go @@ -32,6 +32,14 @@ func TestServerCapabilities(t *testing.T) { GetProviderSchemaOptional: true, }, }, + "MoveResourceState": { + fw: &fwserver.ServerCapabilities{ + MoveResourceState: true, + }, + expected: &tfprotov6.ServerCapabilities{ + MoveResourceState: true, + }, + }, "PlanDestroy": { fw: &fwserver.ServerCapabilities{ PlanDestroy: true,