Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
9 changes: 9 additions & 0 deletions internal/logging/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ func ActionContext(ctx context.Context, action string) context.Context {
return ctx
}

// StateStoreContext injects the state store type into logger contexts.
func StateStoreContext(ctx context.Context, stateStore string) context.Context {
ctx = tfsdklog.SetField(ctx, KeyStateStoreType, stateStore)
ctx = tfsdklog.SubsystemSetField(ctx, SubsystemProto, KeyStateStoreType, stateStore)
ctx = tflog.SetField(ctx, KeyStateStoreType, stateStore)

return ctx
}

// RpcContext injects the RPC name into logger contexts.
func RpcContext(ctx context.Context, rpc string) context.Context {
ctx = tfsdklog.SetField(ctx, KeyRPC, rpc)
Expand Down
3 changes: 3 additions & 0 deletions internal/logging/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ const (
// The action being operated on
KeyActionType = "tf_action_type"

// The type of state store being operated on, such as "terraform_fs"
KeyStateStoreType = "tf_state_store_type"

// Path to protocol data file, such as "/tmp/example.json"
KeyProtocolDataFile = "tf_proto_data_file"

Expand Down
89 changes: 89 additions & 0 deletions tfprotov6/internal/fromproto/state_store.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package fromproto

import (
"github.com/hashicorp/terraform-plugin-go/tfprotov6"
"github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6"
)

func ValidateStateStoreRequest(in *tfplugin6.ValidateStateStore_Request) *tfprotov6.ValidateStateStoreRequest {
if in == nil {
return nil
}

return &tfprotov6.ValidateStateStoreRequest{
TypeName: in.TypeName,
Config: DynamicValue(in.Config),
}
}

func ConfigureStateStoreRequest(in *tfplugin6.ConfigureStateStore_Request) *tfprotov6.ConfigureStateStoreRequest {
if in == nil {
return nil
}

return &tfprotov6.ConfigureStateStoreRequest{
TypeName: in.TypeName,
Config: DynamicValue(in.Config),
Capabilities: tfprotov6.StateStoreClientCapabilities{
ChunkSize: in.Capabilities.ChunkSize,
},
}
}

func ReadStateBytesRequest(in *tfplugin6.ReadStateBytes_Request) *tfprotov6.ReadStateBytesRequest {
if in == nil {
return nil
}

return &tfprotov6.ReadStateBytesRequest{
TypeName: in.TypeName,
StateId: in.StateId,
}
}

func GetStatesRequest(in *tfplugin6.GetStates_Request) *tfprotov6.GetStatesRequest {
if in == nil {
return nil
}

return &tfprotov6.GetStatesRequest{
TypeName: in.TypeName,
}
}

func DeleteStateRequest(in *tfplugin6.DeleteState_Request) *tfprotov6.DeleteStateRequest {
if in == nil {
return nil
}

return &tfprotov6.DeleteStateRequest{
TypeName: in.TypeName,
StateId: in.StateId,
}
}

func LockStateRequest(in *tfplugin6.LockState_Request) *tfprotov6.LockStateRequest {
if in == nil {
return nil
}

return &tfprotov6.LockStateRequest{
TypeName: in.TypeName,
StateId: in.StateId,
Operation: in.Operation,
}
}

func UnlockStateRequest(in *tfplugin6.UnlockState_Request) *tfprotov6.UnlockStateRequest {
if in == nil {
return nil
}

return &tfprotov6.UnlockStateRequest{
TypeName: in.TypeName,
StateId: in.StateId,
}
}
Loading
Loading