浏览代码

dep ensure

yixiong.jxy 7 年之前
父节点
当前提交
9786063aa3

+ 3 - 2
Gopkg.lock

@@ -10,7 +10,8 @@
 [[projects]]
   name = "github.com/jmespath/go-jmespath"
   packages = ["."]
-  revision = "0b12d6b5"
+  revision = "3433f3ea46d9f8019119e7dd41274e112a2359a9"
+  version = "0.2.2"
 
 [[projects]]
   name = "github.com/json-iterator/go"
@@ -72,6 +73,6 @@
 [solve-meta]
   analyzer-name = "dep"
   analyzer-version = 1
-  inputs-digest = "d0ac3538ad51346f28f4bfa6f46b8a6b57847e683a90398178ebd7e5336f8aca"
+  inputs-digest = "bc688a70dca76f7e57da66641e374b6fcd0c715afb0b38f71cbfaebdbd02075f"
   solver-name = "gps-cdcl"
   solver-version = 1

+ 1 - 1
vendor/github.com/jmespath/go-jmespath/Makefile

@@ -35,7 +35,7 @@ buildfuzz:
 	go-fuzz-build github.com/jmespath/go-jmespath/fuzz
 
 fuzz: buildfuzz
-	go-fuzz -bin=./jmespath-fuzz.zip -workdir=fuzz/testdata
+	go-fuzz -bin=./jmespath-fuzz.zip -workdir=fuzz/corpus
 
 bench:
 	go test -bench . -cpuprofile cpu.out

+ 0 - 37
vendor/github.com/jmespath/go-jmespath/api.go

@@ -1,42 +1,5 @@
 package jmespath
 
-import "strconv"
-
-// JmesPath is the epresentation of a compiled JMES path query. A JmesPath is
-// safe for concurrent use by multiple goroutines.
-type JMESPath struct {
-	ast  ASTNode
-	intr *treeInterpreter
-}
-
-// Compile parses a JMESPath expression and returns, if successful, a JMESPath
-// object that can be used to match against data.
-func Compile(expression string) (*JMESPath, error) {
-	parser := NewParser()
-	ast, err := parser.Parse(expression)
-	if err != nil {
-		return nil, err
-	}
-	jmespath := &JMESPath{ast: ast, intr: newInterpreter()}
-	return jmespath, nil
-}
-
-// MustCompile is like Compile but panics if the expression cannot be parsed.
-// It simplifies safe initialization of global variables holding compiled
-// JMESPaths.
-func MustCompile(expression string) *JMESPath {
-	jmespath, err := Compile(expression)
-	if err != nil {
-		panic(`jmespath: Compile(` + strconv.Quote(expression) + `): ` + err.Error())
-	}
-	return jmespath
-}
-
-// Search evaluates a JMESPath expression against input data and returns the result.
-func (jp *JMESPath) Search(data interface{}) (interface{}, error) {
-	return jp.intr.Execute(jp.ast, data)
-}
-
 // Search evaluates a JMESPath expression against input data and returns the result.
 func Search(expression string, data interface{}) (interface{}, error) {
 	intr := newInterpreter()

+ 63 - 65
vendor/github.com/jmespath/go-jmespath/functions.go

@@ -5,7 +5,6 @@ import (
 	"errors"
 	"fmt"
 	"math"
-	"reflect"
 	"sort"
 	"strconv"
 	"strings"
@@ -125,197 +124,197 @@ type functionCaller struct {
 func newFunctionCaller() *functionCaller {
 	caller := &functionCaller{}
 	caller.functionTable = map[string]functionEntry{
-		"length": {
+		"length": functionEntry{
 			name: "length",
 			arguments: []argSpec{
-				{types: []jpType{jpString, jpArray, jpObject}},
+				argSpec{types: []jpType{jpString, jpArray, jpObject}},
 			},
 			handler: jpfLength,
 		},
-		"starts_with": {
+		"starts_with": functionEntry{
 			name: "starts_with",
 			arguments: []argSpec{
-				{types: []jpType{jpString}},
-				{types: []jpType{jpString}},
+				argSpec{types: []jpType{jpString}},
+				argSpec{types: []jpType{jpString}},
 			},
 			handler: jpfStartsWith,
 		},
-		"abs": {
+		"abs": functionEntry{
 			name: "abs",
 			arguments: []argSpec{
-				{types: []jpType{jpNumber}},
+				argSpec{types: []jpType{jpNumber}},
 			},
 			handler: jpfAbs,
 		},
-		"avg": {
+		"avg": functionEntry{
 			name: "avg",
 			arguments: []argSpec{
-				{types: []jpType{jpArrayNumber}},
+				argSpec{types: []jpType{jpArrayNumber}},
 			},
 			handler: jpfAvg,
 		},
-		"ceil": {
+		"ceil": functionEntry{
 			name: "ceil",
 			arguments: []argSpec{
-				{types: []jpType{jpNumber}},
+				argSpec{types: []jpType{jpNumber}},
 			},
 			handler: jpfCeil,
 		},
-		"contains": {
+		"contains": functionEntry{
 			name: "contains",
 			arguments: []argSpec{
-				{types: []jpType{jpArray, jpString}},
-				{types: []jpType{jpAny}},
+				argSpec{types: []jpType{jpArray, jpString}},
+				argSpec{types: []jpType{jpAny}},
 			},
 			handler: jpfContains,
 		},
-		"ends_with": {
+		"ends_with": functionEntry{
 			name: "ends_with",
 			arguments: []argSpec{
-				{types: []jpType{jpString}},
-				{types: []jpType{jpString}},
+				argSpec{types: []jpType{jpString}},
+				argSpec{types: []jpType{jpString}},
 			},
 			handler: jpfEndsWith,
 		},
-		"floor": {
+		"floor": functionEntry{
 			name: "floor",
 			arguments: []argSpec{
-				{types: []jpType{jpNumber}},
+				argSpec{types: []jpType{jpNumber}},
 			},
 			handler: jpfFloor,
 		},
-		"map": {
+		"map": functionEntry{
 			name: "amp",
 			arguments: []argSpec{
-				{types: []jpType{jpExpref}},
-				{types: []jpType{jpArray}},
+				argSpec{types: []jpType{jpExpref}},
+				argSpec{types: []jpType{jpArray}},
 			},
 			handler:   jpfMap,
 			hasExpRef: true,
 		},
-		"max": {
+		"max": functionEntry{
 			name: "max",
 			arguments: []argSpec{
-				{types: []jpType{jpArrayNumber, jpArrayString}},
+				argSpec{types: []jpType{jpArrayNumber, jpArrayString}},
 			},
 			handler: jpfMax,
 		},
-		"merge": {
+		"merge": functionEntry{
 			name: "merge",
 			arguments: []argSpec{
-				{types: []jpType{jpObject}, variadic: true},
+				argSpec{types: []jpType{jpObject}, variadic: true},
 			},
 			handler: jpfMerge,
 		},
-		"max_by": {
+		"max_by": functionEntry{
 			name: "max_by",
 			arguments: []argSpec{
-				{types: []jpType{jpArray}},
-				{types: []jpType{jpExpref}},
+				argSpec{types: []jpType{jpArray}},
+				argSpec{types: []jpType{jpExpref}},
 			},
 			handler:   jpfMaxBy,
 			hasExpRef: true,
 		},
-		"sum": {
+		"sum": functionEntry{
 			name: "sum",
 			arguments: []argSpec{
-				{types: []jpType{jpArrayNumber}},
+				argSpec{types: []jpType{jpArrayNumber}},
 			},
 			handler: jpfSum,
 		},
-		"min": {
+		"min": functionEntry{
 			name: "min",
 			arguments: []argSpec{
-				{types: []jpType{jpArrayNumber, jpArrayString}},
+				argSpec{types: []jpType{jpArrayNumber, jpArrayString}},
 			},
 			handler: jpfMin,
 		},
-		"min_by": {
+		"min_by": functionEntry{
 			name: "min_by",
 			arguments: []argSpec{
-				{types: []jpType{jpArray}},
-				{types: []jpType{jpExpref}},
+				argSpec{types: []jpType{jpArray}},
+				argSpec{types: []jpType{jpExpref}},
 			},
 			handler:   jpfMinBy,
 			hasExpRef: true,
 		},
-		"type": {
+		"type": functionEntry{
 			name: "type",
 			arguments: []argSpec{
-				{types: []jpType{jpAny}},
+				argSpec{types: []jpType{jpAny}},
 			},
 			handler: jpfType,
 		},
-		"keys": {
+		"keys": functionEntry{
 			name: "keys",
 			arguments: []argSpec{
-				{types: []jpType{jpObject}},
+				argSpec{types: []jpType{jpObject}},
 			},
 			handler: jpfKeys,
 		},
-		"values": {
+		"values": functionEntry{
 			name: "values",
 			arguments: []argSpec{
-				{types: []jpType{jpObject}},
+				argSpec{types: []jpType{jpObject}},
 			},
 			handler: jpfValues,
 		},
-		"sort": {
+		"sort": functionEntry{
 			name: "sort",
 			arguments: []argSpec{
-				{types: []jpType{jpArrayString, jpArrayNumber}},
+				argSpec{types: []jpType{jpArrayString, jpArrayNumber}},
 			},
 			handler: jpfSort,
 		},
-		"sort_by": {
+		"sort_by": functionEntry{
 			name: "sort_by",
 			arguments: []argSpec{
-				{types: []jpType{jpArray}},
-				{types: []jpType{jpExpref}},
+				argSpec{types: []jpType{jpArray}},
+				argSpec{types: []jpType{jpExpref}},
 			},
 			handler:   jpfSortBy,
 			hasExpRef: true,
 		},
-		"join": {
+		"join": functionEntry{
 			name: "join",
 			arguments: []argSpec{
-				{types: []jpType{jpString}},
-				{types: []jpType{jpArrayString}},
+				argSpec{types: []jpType{jpString}},
+				argSpec{types: []jpType{jpArrayString}},
 			},
 			handler: jpfJoin,
 		},
-		"reverse": {
+		"reverse": functionEntry{
 			name: "reverse",
 			arguments: []argSpec{
-				{types: []jpType{jpArray, jpString}},
+				argSpec{types: []jpType{jpArray, jpString}},
 			},
 			handler: jpfReverse,
 		},
-		"to_array": {
+		"to_array": functionEntry{
 			name: "to_array",
 			arguments: []argSpec{
-				{types: []jpType{jpAny}},
+				argSpec{types: []jpType{jpAny}},
 			},
 			handler: jpfToArray,
 		},
-		"to_string": {
+		"to_string": functionEntry{
 			name: "to_string",
 			arguments: []argSpec{
-				{types: []jpType{jpAny}},
+				argSpec{types: []jpType{jpAny}},
 			},
 			handler: jpfToString,
 		},
-		"to_number": {
+		"to_number": functionEntry{
 			name: "to_number",
 			arguments: []argSpec{
-				{types: []jpType{jpAny}},
+				argSpec{types: []jpType{jpAny}},
 			},
 			handler: jpfToNumber,
 		},
-		"not_null": {
+		"not_null": functionEntry{
 			name: "not_null",
 			arguments: []argSpec{
-				{types: []jpType{jpAny}, variadic: true},
+				argSpec{types: []jpType{jpAny}, variadic: true},
 			},
 			handler: jpfNotNull,
 		},
@@ -358,7 +357,7 @@ func (a *argSpec) typeCheck(arg interface{}) error {
 				return nil
 			}
 		case jpArray:
-			if isSliceType(arg) {
+			if _, ok := arg.([]interface{}); ok {
 				return nil
 			}
 		case jpObject:
@@ -410,9 +409,8 @@ func jpfLength(arguments []interface{}) (interface{}, error) {
 	arg := arguments[0]
 	if c, ok := arg.(string); ok {
 		return float64(utf8.RuneCountInString(c)), nil
-	} else if isSliceType(arg) {
-		v := reflect.ValueOf(arg)
-		return float64(v.Len()), nil
+	} else if c, ok := arg.([]interface{}); ok {
+		return float64(len(c)), nil
 	} else if c, ok := arg.(map[string]interface{}); ok {
 		return float64(len(c)), nil
 	}

+ 2 - 2
vendor/github.com/jmespath/go-jmespath/parser.go

@@ -353,7 +353,7 @@ func (p *Parser) nud(token token) (ASTNode, error) {
 	case tFlatten:
 		left := ASTNode{
 			nodeType: ASTFlatten,
-			children: []ASTNode{{nodeType: ASTIdentity}},
+			children: []ASTNode{ASTNode{nodeType: ASTIdentity}},
 		}
 		right, err := p.parseProjectionRHS(bindingPowers[tFlatten])
 		if err != nil {
@@ -378,7 +378,7 @@ func (p *Parser) nud(token token) (ASTNode, error) {
 			}
 			return ASTNode{
 				nodeType: ASTProjection,
-				children: []ASTNode{{nodeType: ASTIdentity}, right},
+				children: []ASTNode{ASTNode{nodeType: ASTIdentity}, right},
 			}, nil
 		} else {
 			return p.parseMultiSelectList()