From b25d0251ca606b4ed0618ef10ccaa36ad93aa7d5 Mon Sep 17 00:00:00 2001 From: Pam Selle <204372+pselle@users.noreply.github.com> Date: Wed, 13 Jan 2021 15:14:19 -0500 Subject: [PATCH] Add name to untaint missing warning --- command/untaint.go | 2 +- command/untaint_test.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/command/untaint.go b/command/untaint.go index 13d2bd717..d11c88648 100644 --- a/command/untaint.go +++ b/command/untaint.go @@ -236,7 +236,7 @@ func (c *UntaintCommand) allowMissingExit(name addrs.AbsResourceInstance) int { c.showDiagnostics(tfdiags.Sourceless( tfdiags.Warning, "No such resource instance", - "Resource instance %s was not found, but this is not an error because -allow-missing was set.", + fmt.Sprintf("Resource instance %s was not found, but this is not an error because -allow-missing was set.", name), )) return 0 } diff --git a/command/untaint_test.go b/command/untaint_test.go index 3ef0dbf75..6ff2ba8a3 100644 --- a/command/untaint_test.go +++ b/command/untaint_test.go @@ -5,6 +5,7 @@ import ( "strings" "testing" + "github.com/google/go-cmp/cmp" "github.com/hashicorp/terraform/addrs" "github.com/hashicorp/terraform/states" "github.com/mitchellh/cli" @@ -385,6 +386,18 @@ func TestUntaint_missingAllow(t *testing.T) { if code := c.Run(args); code != 0 { t.Fatalf("bad: %d\n\n%s", code, ui.ErrorWriter.String()) } + + // Check for the warning + actual := strings.TrimSpace(ui.ErrorWriter.String()) + expected := strings.TrimSpace(` +Warning: No such resource instance + +Resource instance test_instance.bar was not found, but this is not an error +because -allow-missing was set. +`) + if diff := cmp.Diff(expected, actual); diff != "" { + t.Fatalf("wrong output\n%s", diff) + } } func TestUntaint_stateOut(t *testing.T) {