Skip to content

Commit

Permalink
logging: add missing capability MoveResourceState (#432)
Browse files Browse the repository at this point in the history
* logging: add missing capability MoveResourceState

---------
  • Loading branch information
grongor authored Sep 17, 2024
1 parent 11902aa commit 94d8cc5
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/unreleased/BUG FIXES-20240917-162414.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: BUG FIXES
body: 'logging: Add existing `MoveResourceState` server capability to v5 and v6 logging'
time: 2024-09-17T16:24:14.06442-04:00
custom:
Issue: "432"
3 changes: 3 additions & 0 deletions internal/logging/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ const (
// Whether the GetProviderSchemaOptional server capability is enabled
KeyServerCapabilityGetProviderSchemaOptional = "tf_server_capability_get_provider_schema_optional"

// Whether the MoveResourceState server capability is enabled
KeyServerCapabilityMoveResourceState = "tf_server_capability_move_resource_state"

// Whether the PlanDestroy server capability is enabled
KeyServerCapabilityPlanDestroy = "tf_server_capability_plan_destroy"

Expand Down
2 changes: 2 additions & 0 deletions tfprotov5/internal/tf5serverlogging/server_capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import (
func ServerCapabilities(ctx context.Context, capabilities *tfprotov5.ServerCapabilities) {
responseFields := map[string]interface{}{
logging.KeyServerCapabilityGetProviderSchemaOptional: false,
logging.KeyServerCapabilityMoveResourceState: false,
logging.KeyServerCapabilityPlanDestroy: false,
}

if capabilities != nil {
responseFields[logging.KeyServerCapabilityGetProviderSchemaOptional] = capabilities.GetProviderSchemaOptional
responseFields[logging.KeyServerCapabilityMoveResourceState] = capabilities.MoveResourceState
responseFields[logging.KeyServerCapabilityPlanDestroy] = capabilities.PlanDestroy
}

Expand Down
19 changes: 19 additions & 0 deletions tfprotov5/internal/tf5serverlogging/server_capabilities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestServerCapabilities(t *testing.T) {
"@message": "Announced server capabilities",
"@module": "sdk.proto",
"tf_server_capability_get_provider_schema_optional": false,
"tf_server_capability_move_resource_state": false,
"tf_server_capability_plan_destroy": false,
},
},
Expand All @@ -43,6 +44,7 @@ func TestServerCapabilities(t *testing.T) {
"@message": "Announced server capabilities",
"@module": "sdk.proto",
"tf_server_capability_get_provider_schema_optional": false,
"tf_server_capability_move_resource_state": false,
"tf_server_capability_plan_destroy": false,
},
},
Expand All @@ -57,6 +59,22 @@ func TestServerCapabilities(t *testing.T) {
"@message": "Announced server capabilities",
"@module": "sdk.proto",
"tf_server_capability_get_provider_schema_optional": true,
"tf_server_capability_move_resource_state": false,
"tf_server_capability_plan_destroy": false,
},
},
},
"move_resource_state": {
capabilities: &tfprotov5.ServerCapabilities{
MoveResourceState: true,
},
expected: []map[string]interface{}{
{
"@level": "trace",
"@message": "Announced server capabilities",
"@module": "sdk.proto",
"tf_server_capability_get_provider_schema_optional": false,
"tf_server_capability_move_resource_state": true,
"tf_server_capability_plan_destroy": false,
},
},
Expand All @@ -71,6 +89,7 @@ func TestServerCapabilities(t *testing.T) {
"@message": "Announced server capabilities",
"@module": "sdk.proto",
"tf_server_capability_get_provider_schema_optional": false,
"tf_server_capability_move_resource_state": false,
"tf_server_capability_plan_destroy": true,
},
},
Expand Down
2 changes: 2 additions & 0 deletions tfprotov6/internal/tf6serverlogging/server_capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ import (
func ServerCapabilities(ctx context.Context, capabilities *tfprotov6.ServerCapabilities) {
responseFields := map[string]interface{}{
logging.KeyServerCapabilityGetProviderSchemaOptional: false,
logging.KeyServerCapabilityMoveResourceState: false,
logging.KeyServerCapabilityPlanDestroy: false,
}

if capabilities != nil {
responseFields[logging.KeyServerCapabilityGetProviderSchemaOptional] = capabilities.GetProviderSchemaOptional
responseFields[logging.KeyServerCapabilityMoveResourceState] = capabilities.MoveResourceState
responseFields[logging.KeyServerCapabilityPlanDestroy] = capabilities.PlanDestroy
}

Expand Down
19 changes: 19 additions & 0 deletions tfprotov6/internal/tf6serverlogging/server_capabilities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestServerCapabilities(t *testing.T) {
"@message": "Announced server capabilities",
"@module": "sdk.proto",
"tf_server_capability_get_provider_schema_optional": false,
"tf_server_capability_move_resource_state": false,
"tf_server_capability_plan_destroy": false,
},
},
Expand All @@ -43,6 +44,7 @@ func TestServerCapabilities(t *testing.T) {
"@message": "Announced server capabilities",
"@module": "sdk.proto",
"tf_server_capability_get_provider_schema_optional": false,
"tf_server_capability_move_resource_state": false,
"tf_server_capability_plan_destroy": false,
},
},
Expand All @@ -57,6 +59,22 @@ func TestServerCapabilities(t *testing.T) {
"@message": "Announced server capabilities",
"@module": "sdk.proto",
"tf_server_capability_get_provider_schema_optional": true,
"tf_server_capability_move_resource_state": false,
"tf_server_capability_plan_destroy": false,
},
},
},
"move_resource_state": {
capabilities: &tfprotov6.ServerCapabilities{
MoveResourceState: true,
},
expected: []map[string]interface{}{
{
"@level": "trace",
"@message": "Announced server capabilities",
"@module": "sdk.proto",
"tf_server_capability_get_provider_schema_optional": false,
"tf_server_capability_move_resource_state": true,
"tf_server_capability_plan_destroy": false,
},
},
Expand All @@ -71,6 +89,7 @@ func TestServerCapabilities(t *testing.T) {
"@message": "Announced server capabilities",
"@module": "sdk.proto",
"tf_server_capability_get_provider_schema_optional": false,
"tf_server_capability_move_resource_state": false,
"tf_server_capability_plan_destroy": true,
},
},
Expand Down

0 comments on commit 94d8cc5

Please sign in to comment.