diff: mark diff properly with input/output
This commit is contained in:
parent
7eacacbff2
commit
175b720ab1
|
@ -64,8 +64,14 @@ func testResourceDiffStr(rd *terraform.ResourceDiff) string {
|
|||
newResource = " (forces new resource)"
|
||||
}
|
||||
|
||||
inOut := "IN "
|
||||
if attrDiff.Type == terraform.DiffAttrOutput {
|
||||
inOut = "OUT"
|
||||
}
|
||||
|
||||
buf.WriteString(fmt.Sprintf(
|
||||
" %s:%s %#v => %#v%s\n",
|
||||
" %s %s:%s %#v => %#v%s\n",
|
||||
inOut,
|
||||
attrK,
|
||||
strings.Repeat(" ", keyLen-len(attrK)),
|
||||
attrDiff.Old,
|
||||
|
|
|
@ -56,6 +56,7 @@ func (b *ResourceBuilder) Diff(
|
|||
// boolean.
|
||||
if _, ok := requiresNewSet[k]; ok {
|
||||
attrs[k].RequiresNew = true
|
||||
attrs[k].Type = terraform.DiffAttrInput
|
||||
requiresNew = true
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +68,7 @@ func (b *ResourceBuilder) Diff(
|
|||
Old: s.ID,
|
||||
NewComputed: true,
|
||||
RequiresNew: true,
|
||||
Type: terraform.DiffAttrOutput,
|
||||
}
|
||||
|
||||
for _, k := range b.CreateComputedAttrs {
|
||||
|
@ -74,6 +76,7 @@ func (b *ResourceBuilder) Diff(
|
|||
attrs[k] = &terraform.ResourceAttrDiff{
|
||||
Old: old,
|
||||
NewComputed: true,
|
||||
Type: terraform.DiffAttrOutput,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,23 +145,23 @@ func TestResourceBuilder_vars(t *testing.T) {
|
|||
}
|
||||
|
||||
const testRBNewDiff = `CREATE
|
||||
foo: "" => "bar"
|
||||
id: "" => "<computed>" (forces new resource)
|
||||
private_ip: "" => "<computed>"
|
||||
IN foo: "" => "bar"
|
||||
OUT id: "" => "<computed>" (forces new resource)
|
||||
OUT private_ip: "" => "<computed>"
|
||||
`
|
||||
|
||||
const testRBRequiresNewDiff = `CREATE
|
||||
ami: "foo" => "bar" (forces new resource)
|
||||
id: "1" => "<computed>" (forces new resource)
|
||||
private_ip: "127.0.0.1" => "<computed>"
|
||||
IN ami: "foo" => "bar" (forces new resource)
|
||||
OUT id: "1" => "<computed>" (forces new resource)
|
||||
OUT private_ip: "127.0.0.1" => "<computed>"
|
||||
`
|
||||
|
||||
const testRBUnknownDiff = `CREATE
|
||||
foo: "" => "${var.unknown}"
|
||||
id: "" => "<computed>" (forces new resource)
|
||||
IN foo: "" => "${var.unknown}"
|
||||
OUT id: "" => "<computed>" (forces new resource)
|
||||
`
|
||||
|
||||
const testRBVarsDiff = `CREATE
|
||||
foo: "" => "bar"
|
||||
id: "" => "<computed>" (forces new resource)
|
||||
IN foo: "" => "bar"
|
||||
OUT id: "" => "<computed>" (forces new resource)
|
||||
`
|
||||
|
|
|
@ -155,8 +155,22 @@ type ResourceAttrDiff struct {
|
|||
New string // New Value
|
||||
NewComputed bool // True if new value is computed (unknown currently)
|
||||
RequiresNew bool // True if change requires new resource
|
||||
Type DiffAttrType
|
||||
}
|
||||
|
||||
// DiffAttrType is an enum type that says whether a resource attribute
|
||||
// diff is an input attribute (comes from the configuration) or an
|
||||
// output attribute (comes as a result of applying the configuration). An
|
||||
// example input would be "ami" for AWS and an example output would be
|
||||
// "private_ip".
|
||||
type DiffAttrType byte
|
||||
|
||||
const (
|
||||
DiffAttrUnknown DiffAttrType = iota
|
||||
DiffAttrInput
|
||||
DiffAttrOutput
|
||||
)
|
||||
|
||||
// Empty returns true if this diff encapsulates no changes.
|
||||
// TODO(mitchellh): test
|
||||
func (d *ResourceDiff) Empty() bool {
|
||||
|
|
Loading…
Reference in New Issue