mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-12 04:19:34 +00:00
Fix bug in JSON path parser where an error occurs when a range is empty
Kubernetes-commit: 10634c6093c84acc78181a26c93d8785e12802e4
This commit is contained in:
committed by
Kubernetes Publisher
parent
4ef01cd5e2
commit
135cef183c
@@ -103,13 +103,23 @@ func (j *JSONPath) FindResults(data interface{}) ([][]reflect.Value, error) {
|
||||
if j.beginRange > 0 {
|
||||
j.beginRange--
|
||||
j.inRange++
|
||||
for _, value := range results {
|
||||
if len(results) > 0 {
|
||||
for _, value := range results {
|
||||
j.parser.Root.Nodes = nodes[i+1:]
|
||||
nextResults, err := j.FindResults(value.Interface())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fullResult = append(fullResult, nextResults...)
|
||||
}
|
||||
} else {
|
||||
// If the range has no results, we still need to process the nodes within the range
|
||||
// so the position will advance to the end node
|
||||
j.parser.Root.Nodes = nodes[i+1:]
|
||||
nextResults, err := j.FindResults(value.Interface())
|
||||
_, err := j.FindResults(nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fullResult = append(fullResult, nextResults...)
|
||||
}
|
||||
j.inRange--
|
||||
|
||||
|
Reference in New Issue
Block a user