Merge pull request #9526 from hashicorp/b-resource-config-equal
terraform: ResourceConfig.Equal should sort ComputedKeys
This commit is contained in:
commit
7418f6c48f
|
@ -3,6 +3,7 @@ package terraform
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -144,6 +145,10 @@ func (c *ResourceConfig) Equal(c2 *ResourceConfig) bool {
|
||||||
return c == c2
|
return c == c2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort the computed keys so they're deterministic
|
||||||
|
sort.Strings(c.ComputedKeys)
|
||||||
|
sort.Strings(c2.ComputedKeys)
|
||||||
|
|
||||||
// Two resource configs if their exported properties are equal.
|
// Two resource configs if their exported properties are equal.
|
||||||
// We don't compare "raw" because it is never used again after
|
// We don't compare "raw" because it is never used again after
|
||||||
// initialization and for all intents and purposes they are equal
|
// initialization and for all intents and purposes they are equal
|
||||||
|
|
|
@ -268,6 +268,20 @@ func TestResourceConfigEqual_nil(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestResourceConfigEqual_computedKeyOrder(t *testing.T) {
|
||||||
|
c := map[string]interface{}{"foo": "${a.b.c}"}
|
||||||
|
rc := NewResourceConfig(config.TestRawConfig(t, c))
|
||||||
|
rc2 := NewResourceConfig(config.TestRawConfig(t, c))
|
||||||
|
|
||||||
|
// Set the computed keys manual
|
||||||
|
rc.ComputedKeys = []string{"foo", "bar"}
|
||||||
|
rc2.ComputedKeys = []string{"bar", "foo"}
|
||||||
|
|
||||||
|
if !rc.Equal(rc2) {
|
||||||
|
t.Fatal("should be equal")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func testResourceConfig(
|
func testResourceConfig(
|
||||||
t *testing.T, c map[string]interface{}) *ResourceConfig {
|
t *testing.T, c map[string]interface{}) *ResourceConfig {
|
||||||
raw, err := config.NewRawConfig(c)
|
raw, err := config.NewRawConfig(c)
|
||||||
|
|
|
@ -140,6 +140,9 @@ func (p *shadowResourceProviderReal) ValidateResource(
|
||||||
Errors: errs,
|
Errors: errs,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// With it locked, call SetValue again so that it triggers WaitForChange
|
||||||
|
p.Shared.ValidateResource.SetValue(key, wrapper)
|
||||||
|
|
||||||
// Return the result
|
// Return the result
|
||||||
return warns, errs
|
return warns, errs
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue