Update godeps
This commit is contained in:
parent
1c8773fc98
commit
1bc383f9c5
1723 changed files with 287976 additions and 411028 deletions
14
vendor/k8s.io/kubernetes/pkg/util/jsonpath/jsonpath.go
generated
vendored
14
vendor/k8s.io/kubernetes/pkg/util/jsonpath/jsonpath.go
generated
vendored
|
|
@ -34,6 +34,8 @@ type JSONPath struct {
|
|||
beginRange int
|
||||
inRange int
|
||||
endRange int
|
||||
|
||||
allowMissingKeys bool
|
||||
}
|
||||
|
||||
func New(name string) *JSONPath {
|
||||
|
|
@ -45,6 +47,13 @@ func New(name string) *JSONPath {
|
|||
}
|
||||
}
|
||||
|
||||
// AllowMissingKeys allows a caller to specify whether they want an error if a field or map key
|
||||
// cannot be located, or simply an empty result. The receiver is returned for chaining.
|
||||
func (j *JSONPath) AllowMissingKeys(allow bool) *JSONPath {
|
||||
j.allowMissingKeys = allow
|
||||
return j
|
||||
}
|
||||
|
||||
// Parse parse the given template, return error
|
||||
func (j *JSONPath) Parse(text string) (err error) {
|
||||
j.parser, err = Parse(j.name, text)
|
||||
|
|
@ -305,7 +314,7 @@ func (j *JSONPath) findFieldInValue(value *reflect.Value, node *FieldNode) (refl
|
|||
return value.FieldByName(node.Value), nil
|
||||
}
|
||||
|
||||
// evalField evaluates filed of struct or key of map.
|
||||
// evalField evaluates field of struct or key of map.
|
||||
func (j *JSONPath) evalField(input []reflect.Value, node *FieldNode) ([]reflect.Value, error) {
|
||||
results := []reflect.Value{}
|
||||
// If there's no input, there's no output
|
||||
|
|
@ -338,6 +347,9 @@ func (j *JSONPath) evalField(input []reflect.Value, node *FieldNode) ([]reflect.
|
|||
}
|
||||
}
|
||||
if len(results) == 0 {
|
||||
if j.allowMissingKeys {
|
||||
return results, nil
|
||||
}
|
||||
return results, fmt.Errorf("%s is not found", node.Value)
|
||||
}
|
||||
return results, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue