Merge pull request #27501 from hashicorp/pselle/taint-err
Show resource name in taint -allow-missing warning
This commit is contained in:
commit
1e10051cad
|
@ -267,7 +267,7 @@ func (c *TaintCommand) 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
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/mitchellh/cli"
|
||||
|
||||
"github.com/hashicorp/terraform/addrs"
|
||||
|
@ -357,6 +358,18 @@ func TestTaint_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 TestTaint_stateOut(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue