Skip to content

Commit bcdb61a

Browse files
ndeloofglours
authored andcommitted
prevent panic merging ipam configs
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 4b6419f commit bcdb61a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

override/merge.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,17 @@ func mergeUlimit(_ any, o any, p tree.Path) (any, error) {
227227

228228
func mergeIPAMConfig(c any, o any, path tree.Path) (any, error) {
229229
var ipamConfigs []any
230-
for _, original := range c.([]any) {
230+
configs, ok := c.([]any)
231+
if !ok {
232+
return o, fmt.Errorf("%s: unexpected type %T", path, c)
233+
}
234+
overrides, ok := o.([]any)
235+
if !ok {
236+
return o, fmt.Errorf("%s: unexpected type %T", path, c)
237+
}
238+
for _, original := range configs {
231239
right := convertIntoMapping(original, nil)
232-
for _, override := range o.([]any) {
240+
for _, override := range overrides {
233241
left := convertIntoMapping(override, nil)
234242
if left["subnet"] != right["subnet"] {
235243
// check if left is already in ipamConfigs, add it if not and continue with the next config

0 commit comments

Comments
 (0)