MCPcopy
hub / github.com/kubernetes/client-go / evalIdentifier

Method evalIdentifier

util/jsonpath/jsonpath.go:211–233  ·  view source on GitHub ↗

evalIdentifier evaluates IdentifierNode

(input []reflect.Value, node *IdentifierNode)

Source from the content-addressed store, hash-verified

209
210// evalIdentifier evaluates IdentifierNode
211func (j *JSONPath) evalIdentifier(input []reflect.Value, node *IdentifierNode) ([]reflect.Value, error) {
212 results := []reflect.Value{}
213 switch node.Name {
214 case "range":
215 j.stack = append(j.stack, j.cur)
216 j.beginRange++
217 results = input
218 case "end":
219 if j.endRange < j.inRange { // inside a loop, break the current block
220 j.endRange++
221 break
222 }
223 // the loop is about to end, pop value and continue the following execution
224 if len(j.stack) > 0 {
225 j.cur, j.stack = j.stack[len(j.stack)-1], j.stack[:len(j.stack)-1]
226 } else {
227 return results, fmt.Errorf("not in range, nothing to end")
228 }
229 default:
230 return input, fmt.Errorf("unrecognized identifier %v", node.Name)
231 }
232 return results, nil
233}
234
235// evalArray evaluates ArrayNode
236func (j *JSONPath) evalArray(input []reflect.Value, node *ArrayNode) ([]reflect.Value, error) {

Callers 1

walkMethod · 0.95

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected