mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
Merge pull request #50444 from nikhita/fix-jsonpath-comment-typos
Automatic merge from submit-queue (batch tested with PRs 50386, 50374, 50444, 50382) jsonpath: fix comments Minor fix to the comments. And avoid a named return value. **Release note**: ```release-note NONE ``` /cc @sttts
This commit is contained in:
commit
52b82eda20
@ -38,6 +38,7 @@ type JSONPath struct {
|
||||
allowMissingKeys bool
|
||||
}
|
||||
|
||||
// New creates a new JSONPath with the given name.
|
||||
func New(name string) *JSONPath {
|
||||
return &JSONPath{
|
||||
name: name,
|
||||
@ -54,13 +55,14 @@ func (j *JSONPath) AllowMissingKeys(allow bool) *JSONPath {
|
||||
return j
|
||||
}
|
||||
|
||||
// Parse parse the given template, return error
|
||||
func (j *JSONPath) Parse(text string) (err error) {
|
||||
// Parse parses the given template and returns an error.
|
||||
func (j *JSONPath) Parse(text string) error {
|
||||
var err error
|
||||
j.parser, err = Parse(j.name, text)
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
// Execute bounds data into template and write the result
|
||||
// Execute bounds data into template and writes the result.
|
||||
func (j *JSONPath) Execute(wr io.Writer, data interface{}) error {
|
||||
fullResults, err := j.FindResults(data)
|
||||
if err != nil {
|
||||
@ -116,7 +118,7 @@ func (j *JSONPath) FindResults(data interface{}) ([][]reflect.Value, error) {
|
||||
return fullResult, nil
|
||||
}
|
||||
|
||||
// PrintResults write the results into writer
|
||||
// PrintResults writes the results into writer
|
||||
func (j *JSONPath) PrintResults(wr io.Writer, results []reflect.Value) error {
|
||||
for i, r := range results {
|
||||
text, err := j.evalToText(r)
|
||||
@ -366,7 +368,7 @@ func (j *JSONPath) evalField(input []reflect.Value, node *FieldNode) ([]reflect.
|
||||
return results, nil
|
||||
}
|
||||
|
||||
// evalWildcard extract all contents of the given value
|
||||
// evalWildcard extracts all contents of the given value
|
||||
func (j *JSONPath) evalWildcard(input []reflect.Value, node *WildcardNode) ([]reflect.Value, error) {
|
||||
results := []reflect.Value{}
|
||||
for _, value := range input {
|
||||
@ -393,7 +395,7 @@ func (j *JSONPath) evalWildcard(input []reflect.Value, node *WildcardNode) ([]re
|
||||
return results, nil
|
||||
}
|
||||
|
||||
// evalRecursive visit the given value recursively and push all of them to result
|
||||
// evalRecursive visits the given value recursively and pushes all of them to result
|
||||
func (j *JSONPath) evalRecursive(input []reflect.Value, node *RecursiveNode) ([]reflect.Value, error) {
|
||||
result := []reflect.Value{}
|
||||
for _, value := range input {
|
||||
@ -429,7 +431,7 @@ func (j *JSONPath) evalRecursive(input []reflect.Value, node *RecursiveNode) ([]
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// evalFilter filter array according to FilterNode
|
||||
// evalFilter filters array according to FilterNode
|
||||
func (j *JSONPath) evalFilter(input []reflect.Value, node *FilterNode) ([]reflect.Value, error) {
|
||||
results := []reflect.Value{}
|
||||
for _, value := range input {
|
||||
|
Loading…
Reference in New Issue
Block a user