helper/schema: Get on computed diff should be empty
This commit is contained in:
parent
c9a541d95b
commit
faa4e75960
|
@ -558,7 +558,8 @@ func (d *ResourceData) getPrimitive(
|
||||||
|
|
||||||
if d.diff != nil && source >= getSourceDiff {
|
if d.diff != nil && source >= getSourceDiff {
|
||||||
attrD, ok := d.diff.Attributes[k]
|
attrD, ok := d.diff.Attributes[k]
|
||||||
if ok && !attrD.NewComputed {
|
if ok {
|
||||||
|
if !attrD.NewComputed {
|
||||||
result = attrD.New
|
result = attrD.New
|
||||||
if attrD.NewExtra != nil {
|
if attrD.NewExtra != nil {
|
||||||
// If NewExtra != nil, then we have processed data as the New,
|
// If NewExtra != nil, then we have processed data as the New,
|
||||||
|
@ -572,6 +573,10 @@ func (d *ResourceData) getPrimitive(
|
||||||
}
|
}
|
||||||
|
|
||||||
resultSet = true
|
resultSet = true
|
||||||
|
} else {
|
||||||
|
result = ""
|
||||||
|
resultSet = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@ func TestResourceDataGet(t *testing.T) {
|
||||||
Diff: &terraform.ResourceDiff{
|
Diff: &terraform.ResourceDiff{
|
||||||
Attributes: map[string]*terraform.ResourceAttrDiff{
|
Attributes: map[string]*terraform.ResourceAttrDiff{
|
||||||
"availability_zone": &terraform.ResourceAttrDiff{
|
"availability_zone": &terraform.ResourceAttrDiff{
|
||||||
Old: "",
|
Old: "foo",
|
||||||
New: "",
|
New: "bar",
|
||||||
NewComputed: true,
|
NewComputed: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -117,6 +117,36 @@ func TestResourceDataGet(t *testing.T) {
|
||||||
Value: "bar",
|
Value: "bar",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
Schema: map[string]*Schema{
|
||||||
|
"availability_zone": &Schema{
|
||||||
|
Type: TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
ForceNew: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
State: &terraform.ResourceState{
|
||||||
|
Attributes: map[string]string{
|
||||||
|
"availability_zone": "foo",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
Diff: &terraform.ResourceDiff{
|
||||||
|
Attributes: map[string]*terraform.ResourceAttrDiff{
|
||||||
|
"availability_zone": &terraform.ResourceAttrDiff{
|
||||||
|
Old: "foo",
|
||||||
|
New: "bar",
|
||||||
|
NewComputed: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
Key: "availability_zone",
|
||||||
|
Value: "",
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
Schema: map[string]*Schema{
|
Schema: map[string]*Schema{
|
||||||
"port": &Schema{
|
"port": &Schema{
|
||||||
|
|
Loading…
Reference in New Issue