terraform: IsSet can be called on nil
This commit is contained in:
parent
7980aa96a8
commit
6bef265514
|
@ -129,6 +129,10 @@ func (c *ResourceConfig) Get(k string) (interface{}, bool) {
|
||||||
// raw configuration itself, since a key may be omitted from the raw
|
// raw configuration itself, since a key may be omitted from the raw
|
||||||
// configuration if it is being computed.
|
// configuration if it is being computed.
|
||||||
func (c *ResourceConfig) IsSet(k string) bool {
|
func (c *ResourceConfig) IsSet(k string) bool {
|
||||||
|
if c == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
for _, ck := range c.ComputedKeys {
|
for _, ck := range c.ComputedKeys {
|
||||||
if ck == k {
|
if ck == k {
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue