command: plan formatting for deposed destroy
This commit is contained in:
parent
41c56ad002
commit
8701434b4d
|
@ -114,14 +114,21 @@ func formatPlanModuleExpand(
|
||||||
symbol = "-"
|
symbol = "-"
|
||||||
}
|
}
|
||||||
|
|
||||||
taintStr := ""
|
var extraAttr []string
|
||||||
if rdiff.DestroyTainted {
|
if rdiff.DestroyTainted {
|
||||||
taintStr = " (tainted)"
|
extraAttr = append(extraAttr, "tainted")
|
||||||
|
}
|
||||||
|
if rdiff.DestroyDeposed {
|
||||||
|
extraAttr = append(extraAttr, "deposed")
|
||||||
|
}
|
||||||
|
var extraStr string
|
||||||
|
if len(extraAttr) > 0 {
|
||||||
|
extraStr = fmt.Sprintf(" (%s)", strings.Join(extraAttr, ", "))
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.WriteString(opts.Color.Color(fmt.Sprintf(
|
buf.WriteString(opts.Color.Color(fmt.Sprintf(
|
||||||
"[%s]%s %s%s\n",
|
"[%s]%s %s%s\n",
|
||||||
color, symbol, name, taintStr)))
|
color, symbol, name, extraStr)))
|
||||||
|
|
||||||
// Get all the attributes that are changing, and sort them. Also
|
// Get all the attributes that are changing, and sort them. Also
|
||||||
// determine the longest key so that we can align them all.
|
// determine the longest key so that we can align them all.
|
||||||
|
|
|
@ -8,6 +8,41 @@ import (
|
||||||
"github.com/mitchellh/colorstring"
|
"github.com/mitchellh/colorstring"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Test that a root level data source gets a special plan output on create
|
||||||
|
func TestFormatPlan_destroyDeposed(t *testing.T) {
|
||||||
|
plan := &terraform.Plan{
|
||||||
|
Diff: &terraform.Diff{
|
||||||
|
Modules: []*terraform.ModuleDiff{
|
||||||
|
&terraform.ModuleDiff{
|
||||||
|
Path: []string{"root"},
|
||||||
|
Resources: map[string]*terraform.InstanceDiff{
|
||||||
|
"aws_instance.foo": &terraform.InstanceDiff{
|
||||||
|
DestroyDeposed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
opts := &FormatPlanOpts{
|
||||||
|
Plan: plan,
|
||||||
|
Color: &colorstring.Colorize{
|
||||||
|
Colors: colorstring.DefaultColors,
|
||||||
|
Disable: true,
|
||||||
|
},
|
||||||
|
ModuleDepth: 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
actual := FormatPlan(opts)
|
||||||
|
|
||||||
|
expected := strings.TrimSpace(`
|
||||||
|
- aws_instance.foo (deposed)
|
||||||
|
`)
|
||||||
|
if actual != expected {
|
||||||
|
t.Fatalf("expected:\n\n%s\n\ngot:\n\n%s", expected, actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Test that a root level data source gets a special plan output on create
|
// Test that a root level data source gets a special plan output on create
|
||||||
func TestFormatPlan_rootDataSource(t *testing.T) {
|
func TestFormatPlan_rootDataSource(t *testing.T) {
|
||||||
plan := &terraform.Plan{
|
plan := &terraform.Plan{
|
||||||
|
|
Loading…
Reference in New Issue