Skip to content

[DRAFT] Support for PSS #531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
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
63 changes: 63 additions & 0 deletions tfprotov6/internal/fromproto/state_store.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// 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),
}
}

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,
}
}
Loading