Skip to content

Commit

Permalink
Removing function argument from diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
bendbennett committed Feb 21, 2024
1 parent 76e98fe commit 1819845
Show file tree
Hide file tree
Showing 13 changed files with 1,254 additions and 1,329 deletions.
3 changes: 0 additions & 3 deletions internal/logging/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ const (
// Attribute of the diagnostic being logged.
KeyDiagnosticAttribute = "diagnostic_attribute"

// Function Argument of the diagnostic being logged.
KeyDiagnosticFunctionArgument = "diagnostic_function_argument"

// Number of the error diagnostics.
KeyDiagnosticErrorCount = "diagnostic_error_count"

Expand Down
4 changes: 0 additions & 4 deletions tfprotov5/diagnostic.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ type Diagnostic struct {
// indicate that the problem is with a certain field in the resource,
// which helps users find the source of the problem.
Attribute *tftypes.AttributePath

// FunctionArgument is the positional function argument for aligning
// configuration source.
FunctionArgument *int64
}

// DiagnosticSeverity represents different classes of Diagnostic which affect
Expand Down
4 changes: 0 additions & 4 deletions tfprotov5/internal/diag/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ func (d Diagnostics) Log(ctx context.Context) {
diagnosticFields[logging.KeyDiagnosticAttribute] = diagnostic.Attribute.String()
}

if diagnostic.FunctionArgument != nil {
diagnosticFields[logging.KeyDiagnosticFunctionArgument] = *diagnostic.FunctionArgument
}

switch diagnostic.Severity {
case tfprotov5.DiagnosticSeverityError:
logging.ProtocolError(ctx, "Response contains error diagnostic", diagnosticFields)
Expand Down
1,291 changes: 638 additions & 653 deletions tfprotov5/internal/tfplugin5/tfplugin5.pb.go

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions tfprotov5/internal/tfplugin5/tfplugin5.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ message Diagnostic {
string summary = 2;
string detail = 3;
AttributePath attribute = 4;

// function_argument is the positional function argument for aligning
// configuration source.
optional int64 function_argument = 5;
}

message FunctionError {
Expand Down
9 changes: 4 additions & 5 deletions tfprotov5/internal/toproto/diagnostic.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ func Diagnostic(in *tfprotov5.Diagnostic) *tfplugin5.Diagnostic {
}

resp := &tfplugin5.Diagnostic{
Attribute: AttributePath(in.Attribute),
Detail: ForceValidUTF8(in.Detail),
FunctionArgument: in.FunctionArgument,
Severity: Diagnostic_Severity(in.Severity),
Summary: ForceValidUTF8(in.Summary),
Attribute: AttributePath(in.Attribute),
Detail: ForceValidUTF8(in.Detail),
Severity: Diagnostic_Severity(in.Severity),
Summary: ForceValidUTF8(in.Summary),
}

return resp
Expand Down
10 changes: 1 addition & 9 deletions tfprotov5/internal/toproto/diagnostic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"

"github.com/hashicorp/terraform-plugin-go/tfprotov5"
"github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5"
"github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/toproto"
Expand Down Expand Up @@ -71,15 +72,6 @@ func TestDiagnostic(t *testing.T) {
Severity: tfplugin5.Diagnostic_INVALID,
},
},
"FunctionArgument": {
in: &tfprotov5.Diagnostic{
FunctionArgument: pointer(int64(123)),
},
expected: &tfplugin5.Diagnostic{
FunctionArgument: pointer(int64(123)),
Severity: tfplugin5.Diagnostic_INVALID,
},
},
"Severity": {
in: &tfprotov5.Diagnostic{
Severity: tfprotov5.DiagnosticSeverityError,
Expand Down
4 changes: 0 additions & 4 deletions tfprotov6/diagnostic.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ type Diagnostic struct {
// indicate that the problem is with a certain field in the resource,
// which helps users find the source of the problem.
Attribute *tftypes.AttributePath

// FunctionArgument is the positional function argument for aligning
// configuration source.
FunctionArgument *int64
}

// DiagnosticSeverity represents different classes of Diagnostic which affect
Expand Down
4 changes: 0 additions & 4 deletions tfprotov6/internal/diag/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ func (d Diagnostics) Log(ctx context.Context) {
diagnosticFields[logging.KeyDiagnosticAttribute] = diagnostic.Attribute.String()
}

if diagnostic.FunctionArgument != nil {
diagnosticFields[logging.KeyDiagnosticFunctionArgument] = *diagnostic.FunctionArgument
}

switch diagnostic.Severity {
case tfprotov6.DiagnosticSeverityError:
logging.ProtocolError(ctx, "Response contains error diagnostic", diagnosticFields)
Expand Down
1,227 changes: 606 additions & 621 deletions tfprotov6/internal/tfplugin6/tfplugin6.pb.go

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions tfprotov6/internal/tfplugin6/tfplugin6.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ message Diagnostic {
string summary = 2;
string detail = 3;
AttributePath attribute = 4;

// function_argument is the positional function argument for aligning
// configuration source.
optional int64 function_argument = 5;
}

message FunctionError {
Expand Down
9 changes: 4 additions & 5 deletions tfprotov6/internal/toproto/diagnostic.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ func Diagnostic(in *tfprotov6.Diagnostic) *tfplugin6.Diagnostic {
}

resp := &tfplugin6.Diagnostic{
Attribute: AttributePath(in.Attribute),
Detail: ForceValidUTF8(in.Detail),
FunctionArgument: in.FunctionArgument,
Severity: Diagnostic_Severity(in.Severity),
Summary: ForceValidUTF8(in.Summary),
Attribute: AttributePath(in.Attribute),
Detail: ForceValidUTF8(in.Detail),
Severity: Diagnostic_Severity(in.Severity),
Summary: ForceValidUTF8(in.Summary),
}

return resp
Expand Down
10 changes: 1 addition & 9 deletions tfprotov6/internal/toproto/diagnostic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"

"github.com/hashicorp/terraform-plugin-go/tfprotov6"
"github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6"
"github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/toproto"
Expand Down Expand Up @@ -71,15 +72,6 @@ func TestDiagnostic(t *testing.T) {
Severity: tfplugin6.Diagnostic_INVALID,
},
},
"FunctionArgument": {
in: &tfprotov6.Diagnostic{
FunctionArgument: pointer(int64(123)),
},
expected: &tfplugin6.Diagnostic{
FunctionArgument: pointer(int64(123)),
Severity: tfplugin6.Diagnostic_INVALID,
},
},
"Severity": {
in: &tfprotov6.Diagnostic{
Severity: tfprotov6.DiagnosticSeverityError,
Expand Down

0 comments on commit 1819845

Please sign in to comment.