terraform: ResourceConfig.Get doesn't panic if exceed list bounds
[GH-210]
This commit is contained in:
parent
4a3dff2441
commit
9ecfdc350e
|
@ -149,6 +149,9 @@ func (c *ResourceConfig) get(
|
|||
if err != nil {
|
||||
return nil, false
|
||||
}
|
||||
if i >= int64(cv.Len()) {
|
||||
return nil, false
|
||||
}
|
||||
current = cv.Index(int(i)).Interface()
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -55,6 +55,22 @@ func TestResourceConfigGet(t *testing.T) {
|
|||
Key: "foo",
|
||||
Value: "bar",
|
||||
},
|
||||
|
||||
{
|
||||
Config: map[string]interface{}{
|
||||
"foo": []interface{}{1, 2, 5},
|
||||
},
|
||||
Key: "foo.0",
|
||||
Value: 1,
|
||||
},
|
||||
|
||||
{
|
||||
Config: map[string]interface{}{
|
||||
"foo": []interface{}{1, 2, 5},
|
||||
},
|
||||
Key: "foo.5",
|
||||
Value: nil,
|
||||
},
|
||||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
|
|
Loading…
Reference in New Issue