1
0
mirror of https://github.com/taigrr/yq synced 2025-01-18 04:53:17 -08:00

Fixed merge new array

This commit is contained in:
Mike Farah
2020-01-06 10:12:30 +13:00
parent 1f7f1b0def
commit 690da9ee74
5 changed files with 35 additions and 11 deletions

View File

@@ -234,7 +234,13 @@ func (n *navigator) recurseArray(value *yaml.Node, head string, tail []string, p
if err != nil {
return errors.Wrapf(err, "Error parsing array index '%v' for '%v'", head, PathStackToString(pathStack))
}
for int64(len(value.Content)) <= index {
value.Content = append(value.Content, &yaml.Node{Kind: guessKind(head, tail, 0)})
}
if index >= int64(len(value.Content)) {
log.Debug("index longer than array length, aborting!")
return nil
}
value.Content[index] = n.getOrReplace(value.Content[index], guessKind(head, tail, value.Content[index].Kind))