helper/schema: don't mark things computed if an ID is set
This commit is contained in:
parent
9ed601d541
commit
eff8306a6c
|
@ -401,9 +401,14 @@ func (m schemaMap) diffString(
|
||||||
}
|
}
|
||||||
|
|
||||||
if os == ns {
|
if os == ns {
|
||||||
// They're the same value, return no diff as long as we're not
|
// They're the same value. If there old value is not blank or we
|
||||||
// computing a new value.
|
// have an ID, then return right away since we're already setup.
|
||||||
if os != "" || !schema.Computed {
|
if os != "" || d.Id() != "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, only continue if we're computed
|
||||||
|
if !schema.Computed {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,27 @@ func TestSchemaMap_Diff(t *testing.T) {
|
||||||
Err: false,
|
Err: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
Schema: map[string]*Schema{
|
||||||
|
"availability_zone": &Schema{
|
||||||
|
Type: TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
ForceNew: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
State: &terraform.ResourceState{
|
||||||
|
ID: "foo",
|
||||||
|
},
|
||||||
|
|
||||||
|
Config: map[string]interface{}{},
|
||||||
|
|
||||||
|
Diff: nil,
|
||||||
|
|
||||||
|
Err: false,
|
||||||
|
},
|
||||||
|
|
||||||
// String with StateFunc
|
// String with StateFunc
|
||||||
{
|
{
|
||||||
Schema: map[string]*Schema{
|
Schema: map[string]*Schema{
|
||||||
|
|
Loading…
Reference in New Issue