Skip to content
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

terraform: do not print tf file name in the errors #83

Merged
merged 1 commit into from
Aug 29, 2022
Merged
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: 0 additions & 9 deletions pkg/terraform/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ type LogDiagnostic struct {
Severity string `json:"severity"`
Summary string `json:"summary"`
Detail string `json:"detail"`
Range Range `json:"range"`
}

// Range represents a line range in a Terraform workspace file
type Range struct {
FileName string `json:"filename"`
}

func (t *tfError) Error() string {
Expand All @@ -68,9 +62,6 @@ func newTFError(message string, logs []byte) (string, *tfError) {
m := l.Message
if l.Diagnostic.Severity == levelError && l.Diagnostic.Summary != "" {
m = fmt.Sprintf("%s: %s", l.Diagnostic.Summary, l.Diagnostic.Detail)
if len(l.Diagnostic.Range.FileName) != 0 {
m = m + ": File name: " + l.Diagnostic.Range.FileName
}
}
messages = append(messages, m)
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/terraform/errors/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func TestNewApplyFailed(t *testing.T) {
args: args{
logs: errorLog,
},
wantErrMessage: "apply failed: Missing required argument: The argument \"location\" is required, but no definition was found.: File name: main.tf.json\nMissing required argument: The argument \"name\" is required, but no definition was found.: File name: main.tf.json",
wantErrMessage: "apply failed: Missing required argument: The argument \"location\" is required, but no definition was found.\nMissing required argument: The argument \"name\" is required, but no definition was found.",
},
}
for name, tt := range tests {
Expand Down Expand Up @@ -247,7 +247,7 @@ func TestNewDestroyFailed(t *testing.T) {
args: args{
logs: errorLog,
},
wantErrMessage: "destroy failed: Missing required argument: The argument \"location\" is required, but no definition was found.: File name: main.tf.json\nMissing required argument: The argument \"name\" is required, but no definition was found.: File name: main.tf.json",
wantErrMessage: "destroy failed: Missing required argument: The argument \"location\" is required, but no definition was found.\nMissing required argument: The argument \"name\" is required, but no definition was found.",
},
}
for name, tt := range tests {
Expand Down Expand Up @@ -276,7 +276,7 @@ func TestNewRefreshFailed(t *testing.T) {
args: args{
logs: errorLog,
},
wantErrMessage: "refresh failed: Missing required argument: The argument \"location\" is required, but no definition was found.: File name: main.tf.json\nMissing required argument: The argument \"name\" is required, but no definition was found.: File name: main.tf.json",
wantErrMessage: "refresh failed: Missing required argument: The argument \"location\" is required, but no definition was found.\nMissing required argument: The argument \"name\" is required, but no definition was found.",
},
}
for name, tt := range tests {
Expand Down Expand Up @@ -305,7 +305,7 @@ func TestNewPlanFailed(t *testing.T) {
args: args{
logs: errorLog,
},
wantErrMessage: "plan failed: Missing required argument: The argument \"location\" is required, but no definition was found.: File name: main.tf.json\nMissing required argument: The argument \"name\" is required, but no definition was found.: File name: main.tf.json",
wantErrMessage: "plan failed: Missing required argument: The argument \"location\" is required, but no definition was found.\nMissing required argument: The argument \"name\" is required, but no definition was found.",
},
}
for name, tt := range tests {
Expand Down