Skip to content

Commit b25d025

Browse files
committed
Add name to untaint missing warning
1 parent 61f9d21 commit b25d025

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎command/untaint.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func (c *UntaintCommand) allowMissingExit(name addrs.AbsResourceInstance) int {
236236
c.showDiagnostics(tfdiags.Sourceless(
237237
tfdiags.Warning,
238238
"No such resource instance",
239-
"Resource instance %s was not found, but this is not an error because -allow-missing was set.",
239+
fmt.Sprintf("Resource instance %s was not found, but this is not an error because -allow-missing was set.", name),
240240
))
241241
return 0
242242
}

‎command/untaint_test.go‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"strings"
66
"testing"
77

8+
"github.com/google/go-cmp/cmp"
89
"github.com/hashicorp/terraform/addrs"
910
"github.com/hashicorp/terraform/states"
1011
"github.com/mitchellh/cli"
@@ -385,6 +386,18 @@ func TestUntaint_missingAllow(t *testing.T) {
385386
if code := c.Run(args); code != 0 {
386387
t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String())
387388
}
389+
390+
// Check for the warning
391+
actual := strings.TrimSpace(ui.ErrorWriter.String())
392+
expected := strings.TrimSpace(`
393+
Warning: No such resource instance
394+
395+
Resource instance test_instance.bar was not found, but this is not an error
396+
because -allow-missing was set.
397+
`)
398+
if diff := cmp.Diff(expected, actual); diff != "" {
399+
t.Fatalf("wrong output\n%s", diff)
400+
}
388401
}
389402

390403
func TestUntaint_stateOut(t *testing.T) {

0 commit comments

Comments
 (0)