terraform: IsSet can be called on nil

This commit is contained in:
Mitchell Hashimoto 2014-06-12 23:23:15 -07:00
parent 7980aa96a8
commit 6bef265514
2 changed files with 12 additions and 0 deletions

View File

@ -129,6 +129,10 @@ func (c *ResourceConfig) Get(k string) (interface{}, bool) {
// raw configuration itself, since a key may be omitted from the raw
// configuration if it is being computed.
func (c *ResourceConfig) IsSet(k string) bool {
if c == nil {
return false
}
for _, ck := range c.ComputedKeys {
if ck == k {
return true

View File

@ -167,3 +167,11 @@ func TestResourceConfig_IsSet(t *testing.T) {
}
}
}
func TestResourceConfig_IsSet_nil(t *testing.T) {
var rc *ResourceConfig
if rc.IsSet("foo") {
t.Fatal("bad")
}
}