diff --git a/go.mod b/go.mod index 9aee15cc..7c2f4c34 100644 --- a/go.mod +++ b/go.mod @@ -4,10 +4,10 @@ go 1.16 require ( github.com/google/go-cmp v0.5.7 - github.com/hashicorp/go-hclog v1.1.0 + github.com/hashicorp/go-hclog v1.2.0 github.com/hashicorp/go-plugin v1.4.3 github.com/hashicorp/go-uuid v1.0.2 - github.com/hashicorp/terraform-plugin-log v0.2.1 + github.com/hashicorp/terraform-plugin-log v0.3.0 github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896 github.com/mitchellh/go-testing-interface v1.14.1 github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce diff --git a/go.sum b/go.sum index b3f3ce60..593519b3 100644 --- a/go.sum +++ b/go.sum @@ -54,16 +54,15 @@ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-hclog v1.0.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-hclog v1.1.0 h1:QsGcniKx5/LuX2eYoeL+Np3UKYPNaN7YKpTh29h8rbw= -github.com/hashicorp/go-hclog v1.1.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-hclog v1.2.0 h1:La19f8d7WIlm4ogzNHB0JGqs5AUDAZ2UfCY4sJXcJdM= +github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-plugin v1.4.3 h1:DXmvivbWD5qdiBts9TpBC7BYL1Aia5sxbRgQB+v6UZM= github.com/hashicorp/go-plugin v1.4.3/go.mod h1:5fGEH17QVwTTcR0zV7yhDPLLmFX9YSZ38b18Udy6vYQ= github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/terraform-plugin-log v0.2.1 h1:hl0G6ctSx7DRTE62VNsPWrq7d+JWy1kjk9ApOFrCq3I= -github.com/hashicorp/terraform-plugin-log v0.2.1/go.mod h1:RW/n0x4dyITmenuirZ1ViPQGP5JQdPTZ4Wwc0rLKi94= +github.com/hashicorp/terraform-plugin-log v0.3.0 h1:NPENNOjaJSVX0f7JJTl4f/2JKRPQ7S2ZN9B4NSqq5kA= +github.com/hashicorp/terraform-plugin-log v0.3.0/go.mod h1:EjueSP/HjlyFAsDqt+okpCPjkT4NDynAe32AeDC4vps= github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896 h1:1FGtlkJw87UsTMg5s8jrekrHmUPUJaMcu6ELiVhQrNw= github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896/go.mod h1:bzBPnUIkI0RxauU8Dqo+2KrZZ28Cf48s8V6IHt3p4co= github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0= diff --git a/internal/logging/keys.go b/internal/logging/keys.go index df164b55..3d7af961 100644 --- a/internal/logging/keys.go +++ b/internal/logging/keys.go @@ -5,6 +5,9 @@ package logging // Practitioners or tooling reading logs may be depending on these keys, so be // conscious of that when changing them. const ( + // Underlying error string + KeyError = "error" + // A unique ID for the RPC request KeyRequestID = "tf_req_id" diff --git a/internal/logging/protocol.go b/internal/logging/protocol.go index 85d52faa..9f9c2808 100644 --- a/internal/logging/protocol.go +++ b/internal/logging/protocol.go @@ -12,11 +12,11 @@ const ( ) // ProtocolError emits a protocol subsystem log at ERROR level. -func ProtocolError(ctx context.Context, msg string, args ...interface{}) { - tfsdklog.SubsystemError(ctx, SubsystemProto, msg, args) +func ProtocolError(ctx context.Context, msg string, additionalFields ...map[string]interface{}) { + tfsdklog.SubsystemError(ctx, SubsystemProto, msg, additionalFields...) } // ProtocolTrace emits a protocol subsystem log at TRACE level. -func ProtocolTrace(ctx context.Context, msg string, args ...interface{}) { - tfsdklog.SubsystemTrace(ctx, SubsystemProto, msg, args) +func ProtocolTrace(ctx context.Context, msg string, additionalFields ...map[string]interface{}) { + tfsdklog.SubsystemTrace(ctx, SubsystemProto, msg, additionalFields...) } diff --git a/internal/logging/protocol_data.go b/internal/logging/protocol_data.go index 904fc536..63035823 100644 --- a/internal/logging/protocol_data.go +++ b/internal/logging/protocol_data.go @@ -57,17 +57,18 @@ func ProtocolData(ctx context.Context, dataDir string, rpc string, message strin fileName := fmt.Sprintf("%d_%s_%s_%s.%s", time.Now().Unix(), rpc, message, field, fileExtension) filePath := path.Join(dataDir, fileName) + logFields := map[string]interface{}{KeyProtocolDataFile: filePath} // should not be persisted using With() - ProtocolTrace(ctx, "Writing protocol data file", KeyProtocolDataFile, filePath) + ProtocolTrace(ctx, "Writing protocol data file", logFields) err := os.WriteFile(filePath, fileContents, 0644) if err != nil { - ProtocolError(ctx, fmt.Sprintf("Unable to write protocol data file: %s", err), KeyProtocolDataFile, filePath) + ProtocolError(ctx, fmt.Sprintf("Unable to write protocol data file: %s", err), logFields) return } - ProtocolTrace(ctx, "Wrote protocol data file", KeyProtocolDataFile, filePath) + ProtocolTrace(ctx, "Wrote protocol data file", logFields) } func protocolDataDynamicValue5(_ context.Context, value *tfprotov5.DynamicValue) (string, []byte) { diff --git a/tfprotov5/tf5server/server.go b/tfprotov5/tf5server/server.go index f033bdb7..9ec7abef 100644 --- a/tfprotov5/tf5server/server.go +++ b/tfprotov5/tf5server/server.go @@ -491,19 +491,19 @@ func (s *server) GetSchema(ctx context.Context, req *tfplugin5.GetProviderSchema defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.GetProviderSchemaRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.GetProviderSchema(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") ret, err := toproto.GetProviderSchema_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -518,21 +518,21 @@ func (s *server) PrepareProviderConfig(ctx context.Context, req *tfplugin5.Prepa defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.PrepareProviderConfigRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Request", "Config", r.Config) logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.PrepareProviderConfig(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Response", "PreparedConfig", resp.PreparedConfig) ret, err := toproto.PrepareProviderConfig_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -547,20 +547,20 @@ func (s *server) Configure(ctx context.Context, req *tfplugin5.Configure_Request defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.ConfigureProviderRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Request", "Config", r.Config) logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.ConfigureProvider(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") ret, err := toproto.Configure_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -588,13 +588,13 @@ func (s *server) Stop(ctx context.Context, req *tfplugin5.Stop_Request) (*tfplug defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.StopProviderRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.StopProvider(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") @@ -603,7 +603,7 @@ func (s *server) Stop(ctx context.Context, req *tfplugin5.Stop_Request) (*tfplug logging.ProtocolTrace(ctx, "Closed all our contexts") ret, err := toproto.Stop_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -619,20 +619,20 @@ func (s *server) ValidateDataSourceConfig(ctx context.Context, req *tfplugin5.Va defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.ValidateDataSourceConfigRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Request", "Config", r.Config) logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.ValidateDataSourceConfig(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") ret, err := toproto.ValidateDataSourceConfig_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -648,7 +648,7 @@ func (s *server) ReadDataSource(ctx context.Context, req *tfplugin5.ReadDataSour defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.ReadDataSourceRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Request", "Config", r.Config) @@ -656,14 +656,14 @@ func (s *server) ReadDataSource(ctx context.Context, req *tfplugin5.ReadDataSour logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.ReadDataSource(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Response", "State", resp.State) ret, err := toproto.ReadDataSource_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -679,20 +679,20 @@ func (s *server) ValidateResourceTypeConfig(ctx context.Context, req *tfplugin5. defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.ValidateResourceTypeConfigRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Request", "Config", r.Config) logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.ValidateResourceTypeConfig(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") ret, err := toproto.ValidateResourceTypeConfig_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -708,20 +708,20 @@ func (s *server) UpgradeResourceState(ctx context.Context, req *tfplugin5.Upgrad defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.UpgradeResourceStateRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.UpgradeResourceState(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Response", "UpgradedState", resp.UpgradedState) ret, err := toproto.UpgradeResourceState_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -737,7 +737,7 @@ func (s *server) ReadResource(ctx context.Context, req *tfplugin5.ReadResource_R defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.ReadResourceRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Request", "CurrentState", r.CurrentState) @@ -745,14 +745,14 @@ func (s *server) ReadResource(ctx context.Context, req *tfplugin5.ReadResource_R logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.ReadResource(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Response", "NewState", resp.NewState) ret, err := toproto.ReadResource_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -768,7 +768,7 @@ func (s *server) PlanResourceChange(ctx context.Context, req *tfplugin5.PlanReso defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.PlanResourceChangeRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Request", "Config", r.Config) @@ -778,14 +778,14 @@ func (s *server) PlanResourceChange(ctx context.Context, req *tfplugin5.PlanReso logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.PlanResourceChange(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Response", "PlannedState", resp.PlannedState) ret, err := toproto.PlanResourceChange_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -801,7 +801,7 @@ func (s *server) ApplyResourceChange(ctx context.Context, req *tfplugin5.ApplyRe defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.ApplyResourceChangeRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Request", "Config", r.Config) @@ -811,14 +811,14 @@ func (s *server) ApplyResourceChange(ctx context.Context, req *tfplugin5.ApplyRe logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.ApplyResourceChange(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Response", "NewState", resp.NewState) ret, err := toproto.ApplyResourceChange_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -834,13 +834,13 @@ func (s *server) ImportResourceState(ctx context.Context, req *tfplugin5.ImportR defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.ImportResourceStateRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.ImportResourceState(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") @@ -849,7 +849,7 @@ func (s *server) ImportResourceState(ctx context.Context, req *tfplugin5.ImportR } ret, err := toproto.ImportResourceState_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil diff --git a/tfprotov6/tf6server/server.go b/tfprotov6/tf6server/server.go index 78f2149f..4ed9ece6 100644 --- a/tfprotov6/tf6server/server.go +++ b/tfprotov6/tf6server/server.go @@ -491,19 +491,19 @@ func (s *server) GetProviderSchema(ctx context.Context, req *tfplugin6.GetProvid defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.GetProviderSchemaRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.GetProviderSchema(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") ret, err := toproto.GetProviderSchema_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -518,20 +518,20 @@ func (s *server) ConfigureProvider(ctx context.Context, req *tfplugin6.Configure defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.ConfigureProviderRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Request", "Config", r.Config) logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.ConfigureProvider(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") ret, err := toproto.Configure_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -545,20 +545,20 @@ func (s *server) ValidateProviderConfig(ctx context.Context, req *tfplugin6.Vali defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.ValidateProviderConfigRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Request", "Config", r.Config) logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.ValidateProviderConfig(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") ret, err := toproto.ValidateProviderConfig_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -586,13 +586,13 @@ func (s *server) Stop(ctx context.Context, req *tfplugin6.StopProvider_Request) defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.StopProviderRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.StopProvider(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") @@ -601,7 +601,7 @@ func (s *server) Stop(ctx context.Context, req *tfplugin6.StopProvider_Request) logging.ProtocolTrace(ctx, "Closed all our contexts") ret, err := toproto.Stop_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -617,20 +617,20 @@ func (s *server) ValidateDataResourceConfig(ctx context.Context, req *tfplugin6. defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.ValidateDataResourceConfigRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Request", "Config", r.Config) logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.ValidateDataResourceConfig(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") ret, err := toproto.ValidateDataResourceConfig_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -646,7 +646,7 @@ func (s *server) ReadDataSource(ctx context.Context, req *tfplugin6.ReadDataSour defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.ReadDataSourceRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Request", "Config", r.Config) @@ -654,14 +654,14 @@ func (s *server) ReadDataSource(ctx context.Context, req *tfplugin6.ReadDataSour logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.ReadDataSource(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Response", "State", resp.State) ret, err := toproto.ReadDataSource_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -677,20 +677,20 @@ func (s *server) ValidateResourceConfig(ctx context.Context, req *tfplugin6.Vali defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.ValidateResourceConfigRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Request", "Config", r.Config) logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.ValidateResourceConfig(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") ret, err := toproto.ValidateResourceConfig_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -706,20 +706,20 @@ func (s *server) UpgradeResourceState(ctx context.Context, req *tfplugin6.Upgrad defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.UpgradeResourceStateRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.UpgradeResourceState(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Response", "UpgradedState", resp.UpgradedState) ret, err := toproto.UpgradeResourceState_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -735,7 +735,7 @@ func (s *server) ReadResource(ctx context.Context, req *tfplugin6.ReadResource_R defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.ReadResourceRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Request", "CurrentState", r.CurrentState) @@ -743,14 +743,14 @@ func (s *server) ReadResource(ctx context.Context, req *tfplugin6.ReadResource_R logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.ReadResource(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Response", "NewState", resp.NewState) ret, err := toproto.ReadResource_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -766,7 +766,7 @@ func (s *server) PlanResourceChange(ctx context.Context, req *tfplugin6.PlanReso defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.PlanResourceChangeRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Request", "Config", r.Config) @@ -776,14 +776,14 @@ func (s *server) PlanResourceChange(ctx context.Context, req *tfplugin6.PlanReso logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.PlanResourceChange(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Response", "PlannedState", resp.PlannedState) ret, err := toproto.PlanResourceChange_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -799,7 +799,7 @@ func (s *server) ApplyResourceChange(ctx context.Context, req *tfplugin6.ApplyRe defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.ApplyResourceChangeRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Request", "Config", r.Config) @@ -809,14 +809,14 @@ func (s *server) ApplyResourceChange(ctx context.Context, req *tfplugin6.ApplyRe logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.ApplyResourceChange(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") logging.ProtocolData(ctx, s.protocolDataDir, rpc, "Response", "NewState", resp.NewState) ret, err := toproto.ApplyResourceChange_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil @@ -832,13 +832,13 @@ func (s *server) ImportResourceState(ctx context.Context, req *tfplugin6.ImportR defer logging.ProtocolTrace(ctx, "Served request") r, err := fromproto.ImportResourceStateRequest(req) if err != nil { - logging.ProtocolError(ctx, "Error converting request from protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting request from protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Calling downstream") resp, err := s.downstream.ImportResourceState(ctx, r) if err != nil { - logging.ProtocolError(ctx, "Error from downstream", "error", err) + logging.ProtocolError(ctx, "Error from downstream", map[string]interface{}{logging.KeyError: err}) return nil, err } logging.ProtocolTrace(ctx, "Called downstream") @@ -847,7 +847,7 @@ func (s *server) ImportResourceState(ctx context.Context, req *tfplugin6.ImportR } ret, err := toproto.ImportResourceState_Response(resp) if err != nil { - logging.ProtocolError(ctx, "Error converting response to protobuf", "error", err) + logging.ProtocolError(ctx, "Error converting response to protobuf", map[string]interface{}{logging.KeyError: err}) return nil, err } return ret, nil