Skip to content

Commit

Permalink
fix negative index
Browse files Browse the repository at this point in the history
Signed-off-by: Shuting Zhao <shutting06@gmail.com>
  • Loading branch information
realshuting committed Feb 26, 2021
1 parent 517c60f commit 7795f33
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/engine/mutate/patchesUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ func getObject(path string, resource map[string]interface{}) (interface{}, error
if err != nil {
return nil, fmt.Errorf("cannot parse index in JSON Patch at %s: %v", strings.Join(paths[:i+1], "/"), err)
}
if idx < 0 {
idx = len(strippedResource.([]interface{})) - 1
}
}

if len(strippedResource.([]interface{})) <= idx {
Expand Down

0 comments on commit 7795f33

Please sign in to comment.