From 0ee5d07e667d7c83366bb609e612b0a5804466d6 Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Fri, 19 Jul 2019 16:42:00 -0400 Subject: [PATCH 1/2] Update go-bexpr to v0.1.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This brings in: • `in`/`not in` operators to do substring matching • `matches` / `not matches` operators to perform regex string matching. --- agent/structs/structs_filtering_test.go | 151 ++--- go.mod | 5 +- go.sum | 44 +- vendor/github.com/hashicorp/go-bexpr/ast.go | 6 + .../github.com/hashicorp/go-bexpr/evaluate.go | 21 + .../hashicorp/go-bexpr/field_config.go | 8 +- .../github.com/hashicorp/go-bexpr/grammar.go | 555 ++++++++++-------- .../github.com/hashicorp/go-bexpr/grammar.peg | 9 +- .../github.com/hashicorp/go-bexpr/validate.go | 19 + vendor/modules.txt | 2 +- website/source/api/agent/check.html.md | 22 +- website/source/api/agent/service.html.md | 58 +- website/source/api/catalog.html.md | 153 ++--- website/source/api/features/filtering.html.md | 6 +- website/source/api/health.html.md | 160 ++--- 15 files changed, 668 insertions(+), 551 deletions(-) diff --git a/agent/structs/structs_filtering_test.go b/agent/structs/structs_filtering_test.go index 5671154c3521..10ce3e280af4 100644 --- a/agent/structs/structs_filtering_test.go +++ b/agent/structs/structs_filtering_test.go @@ -27,11 +27,31 @@ type fieldConfigTest struct { expected bexpr.FieldConfigurations } +// ---------------------------------------------------------------------------- +// +// The following are not explicitly tested as they are supporting structures +// nested within the other API responses +// +// ---------------------------------------------------------------------------- + +var expectedFieldConfigServiceAddress bexpr.FieldConfigurations = bexpr.FieldConfigurations{ + "Address": &bexpr.FieldConfiguration{ + StructFieldName: "Address", + CoerceFn: bexpr.CoerceString, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, + }, + "Port": &bexpr.FieldConfiguration{ + StructFieldName: "Port", + CoerceFn: bexpr.CoerceInt, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + }, +} + var expectedFieldConfigMeshGatewayConfig bexpr.FieldConfigurations = bexpr.FieldConfigurations{ "Mode": &bexpr.FieldConfiguration{ StructFieldName: "Mode", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, } @@ -39,27 +59,27 @@ var expectedFieldConfigUpstreams bexpr.FieldConfigurations = bexpr.FieldConfigur "DestinationType": &bexpr.FieldConfiguration{ StructFieldName: "DestinationType", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "DestinationNamespace": &bexpr.FieldConfiguration{ StructFieldName: "DestinationNamespace", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "DestinationName": &bexpr.FieldConfiguration{ StructFieldName: "DestinationName", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "Datacenter": &bexpr.FieldConfiguration{ StructFieldName: "Datacenter", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "LocalBindAddress": &bexpr.FieldConfiguration{ StructFieldName: "LocalBindAddress", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "LocalBindPort": &bexpr.FieldConfiguration{ StructFieldName: "LocalBindPort", @@ -76,17 +96,17 @@ var expectedFieldConfigConnectProxyConfig bexpr.FieldConfigurations = bexpr.Fiel "DestinationServiceName": &bexpr.FieldConfiguration{ StructFieldName: "DestinationServiceName", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "DestinationServiceID": &bexpr.FieldConfiguration{ StructFieldName: "DestinationServiceID", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "LocalServiceAddress": &bexpr.FieldConfiguration{ StructFieldName: "LocalServiceAddress", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "LocalServicePort": &bexpr.FieldConfiguration{ StructFieldName: "LocalServicePort", @@ -128,31 +148,43 @@ var expectedFieldConfigWeights bexpr.FieldConfigurations = bexpr.FieldConfigurat var expectedFieldConfigMapStringValue bexpr.FieldConfigurations = bexpr.FieldConfigurations{ bexpr.FieldNameAny: &bexpr.FieldConfiguration{ CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, + }, +} + +var expectedFieldConfigMapStringServiceAddress bexpr.FieldConfigurations = bexpr.FieldConfigurations{ + bexpr.FieldNameAny: &bexpr.FieldConfiguration{ + SubFields: expectedFieldConfigServiceAddress, }, } -// these are not all in a table because some of them reference each other +// ---------------------------------------------------------------------------- +// +// The following structures are within the test table as they are structures +// that will be sent back at the top level of API responses +// +// ---------------------------------------------------------------------------- + var expectedFieldConfigNode bexpr.FieldConfigurations = bexpr.FieldConfigurations{ "ID": &bexpr.FieldConfiguration{ StructFieldName: "ID", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "Node": &bexpr.FieldConfiguration{ StructFieldName: "Node", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "Address": &bexpr.FieldConfiguration{ StructFieldName: "Address", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "Datacenter": &bexpr.FieldConfiguration{ StructFieldName: "Datacenter", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "TaggedAddresses": &bexpr.FieldConfiguration{ StructFieldName: "TaggedAddresses", @@ -161,7 +193,7 @@ var expectedFieldConfigNode bexpr.FieldConfigurations = bexpr.FieldConfiguration SubFields: bexpr.FieldConfigurations{ bexpr.FieldNameAny: &bexpr.FieldConfiguration{ CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, }, }, @@ -172,40 +204,27 @@ var expectedFieldConfigNode bexpr.FieldConfigurations = bexpr.FieldConfiguration SubFields: bexpr.FieldConfigurations{ bexpr.FieldNameAny: &bexpr.FieldConfiguration{ CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, }, }, } -var expectedFieldConfigMapStringServiceAddress bexpr.FieldConfigurations = bexpr.FieldConfigurations{ - "Address": &bexpr.FieldConfiguration{ - StructFieldName: "Address", - CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, - }, - "Port": &bexpr.FieldConfiguration{ - StructFieldName: "Port", - CoerceFn: bexpr.CoerceInt, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, - }, -} - var expectedFieldConfigNodeService bexpr.FieldConfigurations = bexpr.FieldConfigurations{ "Kind": &bexpr.FieldConfiguration{ StructFieldName: "Kind", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "ID": &bexpr.FieldConfiguration{ StructFieldName: "ID", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "Service": &bexpr.FieldConfiguration{ StructFieldName: "Service", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "Tags": &bexpr.FieldConfiguration{ StructFieldName: "Tags", @@ -215,17 +234,13 @@ var expectedFieldConfigNodeService bexpr.FieldConfigurations = bexpr.FieldConfig "Address": &bexpr.FieldConfiguration{ StructFieldName: "Address", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "TaggedAddresses": &bexpr.FieldConfiguration{ StructFieldName: "TaggedAddresses", CoerceFn: bexpr.CoerceString, SupportedOperations: []bexpr.MatchOperator{bexpr.MatchIsEmpty, bexpr.MatchIsNotEmpty, bexpr.MatchIn, bexpr.MatchNotIn}, - SubFields: bexpr.FieldConfigurations{ - bexpr.FieldNameAny: &bexpr.FieldConfiguration{ - SubFields: expectedFieldConfigMapStringServiceAddress, - }, - }, + SubFields: expectedFieldConfigMapStringServiceAddress, }, "Meta": &bexpr.FieldConfiguration{ StructFieldName: "Meta", @@ -261,22 +276,22 @@ var expectedFieldConfigServiceNode bexpr.FieldConfigurations = bexpr.FieldConfig "ID": &bexpr.FieldConfiguration{ StructFieldName: "ID", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "Node": &bexpr.FieldConfiguration{ StructFieldName: "Node", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "Address": &bexpr.FieldConfiguration{ StructFieldName: "Address", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "Datacenter": &bexpr.FieldConfiguration{ StructFieldName: "Datacenter", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "TaggedAddresses": &bexpr.FieldConfiguration{ StructFieldName: "TaggedAddresses", @@ -293,17 +308,17 @@ var expectedFieldConfigServiceNode bexpr.FieldConfigurations = bexpr.FieldConfig "ServiceKind": &bexpr.FieldConfiguration{ StructFieldName: "ServiceKind", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "ServiceID": &bexpr.FieldConfiguration{ StructFieldName: "ServiceID", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "ServiceName": &bexpr.FieldConfiguration{ StructFieldName: "ServiceName", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "ServiceTags": &bexpr.FieldConfiguration{ StructFieldName: "ServiceTags", @@ -313,17 +328,13 @@ var expectedFieldConfigServiceNode bexpr.FieldConfigurations = bexpr.FieldConfig "ServiceAddress": &bexpr.FieldConfiguration{ StructFieldName: "ServiceAddress", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "ServiceTaggedAddresses": &bexpr.FieldConfiguration{ StructFieldName: "ServiceTaggedAddresses", CoerceFn: bexpr.CoerceString, SupportedOperations: []bexpr.MatchOperator{bexpr.MatchIsEmpty, bexpr.MatchIsNotEmpty, bexpr.MatchIn, bexpr.MatchNotIn}, - SubFields: bexpr.FieldConfigurations{ - bexpr.FieldNameAny: &bexpr.FieldConfiguration{ - SubFields: expectedFieldConfigMapStringServiceAddress, - }, - }, + SubFields: expectedFieldConfigMapStringServiceAddress, }, "ServiceMeta": &bexpr.FieldConfiguration{ StructFieldName: "ServiceMeta", @@ -358,42 +369,42 @@ var expectedFieldConfigServiceNode bexpr.FieldConfigurations = bexpr.FieldConfig var expectedFieldConfigHealthCheck bexpr.FieldConfigurations = bexpr.FieldConfigurations{ "Node": &bexpr.FieldConfiguration{ CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, StructFieldName: "Node", }, "CheckId": &bexpr.FieldConfiguration{ CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, StructFieldName: "CheckId", }, "Name": &bexpr.FieldConfiguration{ CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, StructFieldName: "Name", }, "Status": &bexpr.FieldConfiguration{ CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, StructFieldName: "Status", }, "Notes": &bexpr.FieldConfiguration{ CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, StructFieldName: "Notes", }, "Output": &bexpr.FieldConfiguration{ CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, StructFieldName: "Output", }, "ServiceID": &bexpr.FieldConfiguration{ CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, StructFieldName: "ServiceID", }, "ServiceName": &bexpr.FieldConfiguration{ CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, StructFieldName: "ServiceName", }, "ServiceTags": &bexpr.FieldConfiguration{ @@ -423,39 +434,29 @@ var expectedFieldConfigNodeInfo bexpr.FieldConfigurations = bexpr.FieldConfigura "ID": &bexpr.FieldConfiguration{ StructFieldName: "ID", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "Node": &bexpr.FieldConfiguration{ StructFieldName: "Node", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "Address": &bexpr.FieldConfiguration{ StructFieldName: "Address", CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, + SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual, bexpr.MatchIn, bexpr.MatchNotIn, bexpr.MatchMatches, bexpr.MatchNotMatches}, }, "TaggedAddresses": &bexpr.FieldConfiguration{ StructFieldName: "TaggedAddresses", CoerceFn: bexpr.CoerceString, SupportedOperations: []bexpr.MatchOperator{bexpr.MatchIsEmpty, bexpr.MatchIsNotEmpty, bexpr.MatchIn, bexpr.MatchNotIn}, - SubFields: bexpr.FieldConfigurations{ - bexpr.FieldNameAny: &bexpr.FieldConfiguration{ - CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, - }, - }, + SubFields: expectedFieldConfigMapStringValue, }, "Meta": &bexpr.FieldConfiguration{ StructFieldName: "Meta", CoerceFn: bexpr.CoerceString, SupportedOperations: []bexpr.MatchOperator{bexpr.MatchIsEmpty, bexpr.MatchIsNotEmpty, bexpr.MatchIn, bexpr.MatchNotIn}, - SubFields: bexpr.FieldConfigurations{ - bexpr.FieldNameAny: &bexpr.FieldConfiguration{ - CoerceFn: bexpr.CoerceString, - SupportedOperations: []bexpr.MatchOperator{bexpr.MatchEqual, bexpr.MatchNotEqual}, - }, - }, + SubFields: expectedFieldConfigMapStringValue, }, "Services": &bexpr.FieldConfiguration{ StructFieldName: "Services", diff --git a/go.mod b/go.mod index 44dd7126327d..f1090b0dc454 100644 --- a/go.mod +++ b/go.mod @@ -41,7 +41,6 @@ require ( github.com/gocql/gocql v0.0.0-20180617115710-e06f8c1bcd78 // indirect github.com/gogo/googleapis v1.1.0 github.com/gogo/protobuf v1.2.1 - github.com/golang/lint v0.0.0-20180702182130-06c8688daad7 // indirect github.com/golang/protobuf v1.2.0 github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db // indirect github.com/google/go-cmp v0.2.0 // indirect @@ -50,7 +49,7 @@ require ( github.com/gotestyourself/gotestyourself v2.2.0+incompatible // indirect github.com/hashicorp/consul/api v1.1.0 github.com/hashicorp/consul/sdk v0.1.1 - github.com/hashicorp/go-bexpr v0.1.0 + github.com/hashicorp/go-bexpr v0.1.1 github.com/hashicorp/go-checkpoint v0.0.0-20171009173528-1545e56e46de github.com/hashicorp/go-cleanhttp v0.5.1 github.com/hashicorp/go-discover v0.0.0-20190403160810-22221edb15cd @@ -59,7 +58,6 @@ require ( github.com/hashicorp/go-msgpack v0.5.5 github.com/hashicorp/go-multierror v1.0.0 github.com/hashicorp/go-plugin v0.0.0-20180331002553-e8d22c780116 - github.com/hashicorp/go-rootcerts v1.0.0 github.com/hashicorp/go-sockaddr v1.0.0 github.com/hashicorp/go-syslog v1.0.0 github.com/hashicorp/go-uuid v1.0.1 @@ -83,7 +81,6 @@ require ( github.com/kr/pretty v0.1.0 // indirect github.com/kr/text v0.1.0 github.com/lib/pq v0.0.0-20180523175426-90697d60dd84 // indirect - github.com/lyft/protoc-gen-validate v0.0.0-20180911180927-64fcb82c878e // indirect github.com/miekg/dns v1.0.14 github.com/mitchellh/cli v1.0.0 github.com/mitchellh/copystructure v0.0.0-20160804032330-cdac8253d00f diff --git a/go.sum b/go.sum index c09867f6523f..fde3006098ee 100644 --- a/go.sum +++ b/go.sum @@ -8,8 +8,6 @@ github.com/Azure/go-autorest v10.7.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSW github.com/Azure/go-autorest v10.15.3+incompatible h1:nhKI/bvazIs3C3TFGoSqKY6hZ8f5od5mb5/UcS6HVIY= github.com/Azure/go-autorest v10.15.3+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/DataDog/datadog-go v0.0.0-20160329135253-cc2f4770f4d6 h1:veThyuVPIg0cAHly135Y+IW2ymFgZ1pftOyAVkqCoi8= -github.com/DataDog/datadog-go v0.0.0-20160329135253-cc2f4770f4d6/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/datadog-go v2.2.0+incompatible h1:V5BKkxACZLjzHjSgBbr2gvLA2Ae49yhc6CSY7MLy5k4= github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/Jeffail/gabs v1.1.0 h1:kw5zCcl9tlJNHTDme7qbi21fDHZmXrnjMoXos3Jw/NI= @@ -52,12 +50,8 @@ github.com/boltdb/bolt v1.3.1 h1:JQmyP4ZBrce+ZQu0dY660FMfatumYDLun9hBCUVIkF4= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/cenkalti/backoff v2.1.1+incompatible h1:tKJnvO2kl0zmb/jA5UKAt4VoEVw1qxKWjE/Bpp46npY= github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= -github.com/circonus-labs/circonus-gometrics v0.0.0-20161109192337-d17a8420c36e h1:VhMcRhkS/wJM+XfZxNn+tk5EVmF2k19g6yS6uDXHn0o= -github.com/circonus-labs/circonus-gometrics v0.0.0-20161109192337-d17a8420c36e/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible h1:C29Ae4G5GtYyYMm1aztcyj/J5ckgJm2zwdDajFbx1NY= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= -github.com/circonus-labs/circonusllhist v0.0.0-20161110002650-365d370cc145 h1:cwLvX6r5EOiVmkUYjY+Ev4ZJrkOhex3r+mfeqT8o+8c= -github.com/circonus-labs/circonusllhist v0.0.0-20161110002650-365d370cc145/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/circonus-labs/circonusllhist v0.1.3 h1:TJH+oke8D16535+jHExHj4nQvzlZrj7ug5D7I/orNUA= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= @@ -86,8 +80,6 @@ github.com/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74 h1:2MIh github.com/duosecurity/duo_api_golang v0.0.0-20190308151101-6c680f768e74/go.mod h1:UqXY1lYT/ERa4OEAywUqdok1T4RCRdArkhic1Opuavo= github.com/elazarl/go-bindata-assetfs v0.0.0-20160803192304-e1a2a7ec64b0 h1:ZoRgc53qJCfSLimXqJDrmBhnt5GChDsExMCK7t48o0Y= github.com/elazarl/go-bindata-assetfs v0.0.0-20160803192304-e1a2a7ec64b0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= -github.com/envoyproxy/go-control-plane v0.0.0-20180919002855-2137d9196328 h1:kRYkA4bsDlXqE8xcdVkbtPOB93wyl7NHf790u9ck3ME= -github.com/envoyproxy/go-control-plane v0.0.0-20180919002855-2137d9196328/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.8.0 h1:uE6Fp4fOcAJdc1wTQXLJ+SYistkbG1dNoi6Zs1+Ybvk= github.com/envoyproxy/go-control-plane v0.8.0/go.mod h1:GSSbY9P1neVhdY7G4wu+IK1rk/dqhiCC/4ExuWJZVuk= github.com/envoyproxy/protoc-gen-validate v0.0.14 h1:YBW6/cKy9prEGRYLnaGa4IDhzxZhRCtKsax8srGKDnM= @@ -120,7 +112,6 @@ github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= github.com/golang/mock v1.1.1 h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= @@ -152,8 +143,8 @@ github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-bexpr v0.1.0 h1:hA/9CWGPsQ6YZXvPvizD+VEEjBG4V6Un0Qcyav5ghK4= -github.com/hashicorp/go-bexpr v0.1.0/go.mod h1:ANbpTX1oAql27TZkKVeW8p1w8NTdnyzPe/0qqPCKohU= +github.com/hashicorp/go-bexpr v0.1.1 h1:WvjUsC7elNIAwpFGj7tfqXocJDBQbep0Py9hSNmtrFk= +github.com/hashicorp/go-bexpr v0.1.1/go.mod h1:ANbpTX1oAql27TZkKVeW8p1w8NTdnyzPe/0qqPCKohU= github.com/hashicorp/go-checkpoint v0.0.0-20171009173528-1545e56e46de h1:XDCSythtg8aWSRSO29uwhgh7b127fWr+m5SemqjSUL8= github.com/hashicorp/go-checkpoint v0.0.0-20171009173528-1545e56e46de/go.mod h1:xIwEieBHERyEvaeKF/TcHh1Hu+lxPM+n2vT1+g9I4m4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -161,8 +152,6 @@ github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVo github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-discover v0.0.0-20190403160810-22221edb15cd h1:SynRxs8h2h7lLSA5py5a3WWkYpImhREtju0CuRd97wc= github.com/hashicorp/go-discover v0.0.0-20190403160810-22221edb15cd/go.mod h1:ueUgD9BeIocT7QNuvxSyJyPAM9dfifBcaWmeybb67OY= -github.com/hashicorp/go-hclog v0.0.0-20180402200405-69ff559dc25f h1:t34t/ySFIGsPOLQ/dCcKeCoErlqhXlNLYvPn7mVogzo= -github.com/hashicorp/go-hclog v0.0.0-20180402200405-69ff559dc25f/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= github.com/hashicorp/go-hclog v0.9.1 h1:9PZfAcVEvez4yhLH2TBU64/h/z4xlFI80cWXRrxuKuM= github.com/hashicorp/go-hclog v0.9.1/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= @@ -170,16 +159,12 @@ github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjh github.com/hashicorp/go-memdb v0.0.0-20180223233045-1289e7fffe71 h1:yxxFgVz31vFoKKTtRUNbXLNe4GFnbLKqg+0N7yG42L8= github.com/hashicorp/go-memdb v0.0.0-20180223233045-1289e7fffe71/go.mod h1:kbfItVoBJwCfKXDXN4YoAXjxcFVZ7MRrJzyTX6H4giE= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-msgpack v0.5.4 h1:SFT72YqIkOcLdWJUYcriVX7hbrZpwc/f7h8aW2NUqrA= -github.com/hashicorp/go-msgpack v0.5.4/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI= github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-plugin v0.0.0-20180331002553-e8d22c780116 h1:Y4V/yReWjQo/Ngyc0w6C3EKXKincp4YgvXeo8lI4LrI= github.com/hashicorp/go-plugin v0.0.0-20180331002553-e8d22c780116/go.mod h1:JSqWYsict+jzcj0+xElxyrBQRPNoiWQuddnxArJ7XHQ= -github.com/hashicorp/go-retryablehttp v0.0.0-20180531211321-3b087ef2d313 h1:8YjGfJRRXO9DA6RG0wNt3kEkvvnxIDao5us1PG+S0wc= -github.com/hashicorp/go-retryablehttp v0.0.0-20180531211321-3b087ef2d313/go.mod h1:fXcdFsQoipQa7mwORhKad5jmDCeSy/RCGzWA08PO0lM= github.com/hashicorp/go-retryablehttp v0.5.3 h1:QlWt0KvWT0lq8MFppF9tsJGF+ynG7ztc2KIPhzRGk7s= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0 h1:Rqb66Oo1X/eSV1x66xbDccZjhJigjg0+e82kpwzSwCI= @@ -210,14 +195,10 @@ github.com/hashicorp/mdns v1.0.1 h1:XFSOubp8KWB+Jd2PDyaX5xUd5bhSP/+pTDZVDMzZJM8= github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= github.com/hashicorp/memberlist v0.1.3 h1:EmmoJme1matNzb+hMpDuR/0sbJSUisxyqBGG676r31M= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= -github.com/hashicorp/memberlist v0.1.4-0.20190515174901-e1138a6a4d8a h1:9V2hIf261IZE7KfJtTOAncg/BRrauZblzdyS9lrTl1E= -github.com/hashicorp/memberlist v0.1.4-0.20190515174901-e1138a6a4d8a/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/memberlist v0.1.4 h1:gkyML/r71w3FL8gUi74Vk76avkj/9lYAY9lvg0OcoGs= github.com/hashicorp/memberlist v0.1.4/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/net-rpc-msgpackrpc v0.0.0-20151116020338-a14192a58a69 h1:lc3c72qGlIMDqQpQH82Y4vaglRMMFdJbziYWriR4UcE= github.com/hashicorp/net-rpc-msgpackrpc v0.0.0-20151116020338-a14192a58a69/go.mod h1:/z+jUGRBlwVpUZfjute9jWaF6/HuhjuFQuL1YXzVD1Q= -github.com/hashicorp/raft v1.0.1-0.20190409200437-d9fe23f7d472 h1:9EPzHJ1bJFaFbGOz3UV3DDFmGYANr+SF+eapmiK5zV4= -github.com/hashicorp/raft v1.0.1-0.20190409200437-d9fe23f7d472/go.mod h1:DVSAWItjLjTOkVbSpWQ0j0kUADIvDaCtBxIcbNAQLkI= github.com/hashicorp/raft v1.1.0 h1:qPMePEczgbkiQsqCsRfuHRqvDUO+zmAInDaD5ptXlq0= github.com/hashicorp/raft v1.1.0/go.mod h1:4Ak7FSPnuvmb0GV6vgIAJ4vYT4bek9bb6Q+7HVbyzqM= github.com/hashicorp/raft-boltdb v0.0.0-20150201200839-d1e82c1ec3f1 h1:LHTrLUnNkk+2YkO5EMG49q0lHdR9AZhDbCpu0+M3e0E= @@ -260,8 +241,6 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/lib/pq v0.0.0-20180523175426-90697d60dd84 h1:it29sI2IM490luSc3RAhp5WuCYnc6RtbfLVAB7nmC5M= github.com/lib/pq v0.0.0-20180523175426-90697d60dd84/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lyft/protoc-gen-validate v0.0.0-20180911180927-64fcb82c878e h1:cgOn2iVzS/4UIrPj8PwNb9yW5/o6GVf0wV1ScGOcQKQ= -github.com/lyft/protoc-gen-validate v0.0.0-20180911180927-64fcb82c878e/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-isatty v0.0.3 h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI= @@ -327,20 +306,12 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1 h1:ccV59UEOTzVDnDUEFdT95ZzHVZ+5+158q8+SJb2QV5w= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/prometheus/client_golang v0.0.0-20180328130430-f504d69affe1 h1:jtnwVoXwppTtQ4ApMgCb+G5CcW8OUvLlprWpB+x3e+8= -github.com/prometheus/client_golang v0.0.0-20180328130430-f504d69affe1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.2 h1:awm861/B8OKDd2I/6o1dy3ra4BamzKhYOiGItCeZ740= github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= -github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5 h1:cLL6NowurKLMfCeQy4tIeph12XNQWgANCNvdyrOYKV4= -github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/common v0.0.0-20180326160409-38c53a9f4bfc h1:tyg3EcZAmwCUe90Jzl4Qw6Af+ajuW8S9b1VFitMNOQs= -github.com/prometheus/common v0.0.0-20180326160409-38c53a9f4bfc/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.0.0-20181126121408-4724e9255275 h1:PnBWHBf+6L0jOqq0gIVUe6Yk0/QMZ640k6NvkxcBf+8= github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/procfs v0.0.0-20180408092902-8b1c2da0d56d h1:RCcsxyRr6+/pLg6wr0cUjPovhEhSNOtPh0SOz6u3hGU= -github.com/prometheus/procfs v0.0.0-20180408092902-8b1c2da0d56d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a h1:9a8MnZMP0X2nLJdBg+pBmGgkJlSaKC2KaQmTCk1XDtE= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/renier/xmlrpc v0.0.0-20170708154548-ce4a1a486c03 h1:Wdi9nwnhFNAlseAOekn6B5G/+GMtks9UKbvRU/CMM/o= @@ -385,7 +356,6 @@ golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnf golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -393,8 +363,6 @@ golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519 h1:x6rhz8Y9CjbgQkccRGmELH6K+ golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc h1:a3CU5tJYVj92DY2LaA1kUkrsqD5/3mLDhx2NcNqyW+0= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190403144856-b630fd6fe46b h1:/zjbcJPEGAyu6Is/VBOALsgdi4z9+kz/Vtdm6S+beD0= -golang.org/x/net v0.0.0-20190403144856-b630fd6fe46b/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c h1:uOCk1iQW6Vc18bnC13MfzScl+wdKBmM9Y9kU7Z83/lw= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/oauth2 v0.0.0-20170807180024-9a379c6b3e95/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -403,8 +371,6 @@ golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAG golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -413,8 +379,6 @@ golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5 h1:x6r4Jo0KNzOOzYd8lbcRsqjuqEASK6ob3auvWYM4/8U= golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e h1:nFYrTHrdrAOpShe27kaFHjsqYSEQ0KWqdWLu3xuZJts= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190508220229-2d0786266e9c h1:hDn6jm7snBX2O7+EeTk6Q4WXJfKt7MWgtiCCRi1rBoY= golang.org/x/sys v0.0.0-20190508220229-2d0786266e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= @@ -424,7 +388,6 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 h1:+DCIGbF/swA92ohVg0//6X2IVY3KZs6p9mix0ziNYJM= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= google.golang.org/api v0.0.0-20180829000535-087779f1d2c9 h1:z1TeLUmxf9ws9KLICfmX+KGXTs+rjm+aGWzfsv7MZ9w= @@ -433,8 +396,6 @@ google.golang.org/appengine v1.1.0 h1:igQkv0AAhEIvTEpD5LIpAfav2eeVO9HBTjvKHVJPRS google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/grpc v0.0.0-20180920234847-8997b5fa0873 h1:lD5DGIVfj/bkquhOM/bnbqvmwMFMmQblC3Ujbs8STUY= -google.golang.org/grpc v0.0.0-20180920234847-8997b5fa0873/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= google.golang.org/grpc v1.19.1 h1:TrBcJ1yqAl1G++wO39nD/qtgpsW9/1+QGrluyMGEYgM= google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= gopkg.in/airbrake/gobrake.v2 v2.0.9 h1:7z2uVWwn7oVeeugY1DtlPAy5H+KYgB1KeKTnqjNatLo= @@ -461,7 +422,6 @@ gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= -honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= istio.io/gogo-genproto v0.0.0-20190124151557-6d926a6e6feb/go.mod h1:eIDJ6jNk/IeJz6ODSksHl5Aiczy5JUq6vFhJWI5OtiI= k8s.io/api v0.0.0-20180806132203-61b11ee65332/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= diff --git a/vendor/github.com/hashicorp/go-bexpr/ast.go b/vendor/github.com/hashicorp/go-bexpr/ast.go index be0afc8772ea..42e12fbbacc4 100644 --- a/vendor/github.com/hashicorp/go-bexpr/ast.go +++ b/vendor/github.com/hashicorp/go-bexpr/ast.go @@ -57,6 +57,8 @@ const ( MatchNotIn MatchIsEmpty MatchIsNotEmpty + MatchMatches + MatchNotMatches ) func (op MatchOperator) String() string { @@ -73,6 +75,10 @@ func (op MatchOperator) String() string { return "Is Empty" case MatchIsNotEmpty: return "Is Not Empty" + case MatchMatches: + return "Matches" + case MatchNotMatches: + return "Not Matches" default: return "UNKNOWN" } diff --git a/vendor/github.com/hashicorp/go-bexpr/evaluate.go b/vendor/github.com/hashicorp/go-bexpr/evaluate.go index 8d700e8b1c50..fd78db02332c 100644 --- a/vendor/github.com/hashicorp/go-bexpr/evaluate.go +++ b/vendor/github.com/hashicorp/go-bexpr/evaluate.go @@ -3,9 +3,12 @@ package bexpr import ( "fmt" "reflect" + "regexp" "strings" ) +var byteSliceTyp reflect.Type = reflect.TypeOf([]byte{}) + var primitiveEqualityFns = map[reflect.Kind]func(first interface{}, second reflect.Value) bool{ reflect.Bool: doEqualBool, reflect.Int: doEqualInt, @@ -87,6 +90,16 @@ func derefType(rtype reflect.Type) reflect.Type { return rtype } +func doMatchMatches(expression *MatchExpression, value reflect.Value) (bool, error) { + if !value.Type().ConvertibleTo(byteSliceTyp) { + return false, fmt.Errorf("Value of type %s is not convertible to []byte", value.Type()) + } + + re := expression.Value.Converted.(*regexp.Regexp) + + return re.Match(value.Convert(byteSliceTyp).Interface().([]byte)), nil +} + func doMatchEqual(expression *MatchExpression, value reflect.Value) (bool, error) { // NOTE: see preconditions in evaluateMatchExpressionRecurse eqFn := primitiveEqualityFns[value.Kind()] @@ -186,6 +199,14 @@ func evaluateMatchExpressionRecurse(expression *MatchExpression, depth int, rval return !result, nil } return false, err + case MatchMatches: + return doMatchMatches(expression, rvalue) + case MatchNotMatches: + result, err := doMatchMatches(expression, rvalue) + if err == nil { + return !result, nil + } + return false, err default: return false, fmt.Errorf("Invalid match operation: %d", expression.Operator) } diff --git a/vendor/github.com/hashicorp/go-bexpr/field_config.go b/vendor/github.com/hashicorp/go-bexpr/field_config.go index 9fbc0fbb056d..b2df4d6c2243 100644 --- a/vendor/github.com/hashicorp/go-bexpr/field_config.go +++ b/vendor/github.com/hashicorp/go-bexpr/field_config.go @@ -71,9 +71,15 @@ func generateFieldConfigurationInternal(rtype reflect.Type) (*FieldConfiguration // Handle primitive types if coerceFn, ok := primitiveCoercionFns[rtype.Kind()]; ok { + ops := []MatchOperator{MatchEqual, MatchNotEqual} + + if rtype.Kind() == reflect.String { + ops = append(ops, MatchIn, MatchNotIn, MatchMatches, MatchNotMatches) + } + return &FieldConfiguration{ CoerceFn: coerceFn, - SupportedOperations: []MatchOperator{MatchEqual, MatchNotEqual}, + SupportedOperations: ops, }, nil } diff --git a/vendor/github.com/hashicorp/go-bexpr/grammar.go b/vendor/github.com/hashicorp/go-bexpr/grammar.go index 523d09d9860a..e6b5e59d7bc4 100644 --- a/vendor/github.com/hashicorp/go-bexpr/grammar.go +++ b/vendor/github.com/hashicorp/go-bexpr/grammar.go @@ -452,14 +452,22 @@ var g = &grammar{ pos: position{line: 61, col: 106, offset: 1575}, name: "MatchNotContains", }, + &ruleRefExpr{ + pos: position{line: 61, col: 125, offset: 1594}, + name: "MatchMatches", + }, + &ruleRefExpr{ + pos: position{line: 61, col: 140, offset: 1609}, + name: "MatchNotMatches", + }, }, }, }, &labeledExpr{ - pos: position{line: 61, col: 124, offset: 1593}, + pos: position{line: 61, col: 157, offset: 1626}, label: "value", expr: &ruleRefExpr{ - pos: position{line: 61, col: 130, offset: 1599}, + pos: position{line: 61, col: 163, offset: 1632}, name: "Value", }, }, @@ -470,33 +478,33 @@ var g = &grammar{ { name: "MatchSelectorOp", displayName: "\"match\"", - pos: position{line: 65, col: 1, offset: 1737}, + pos: position{line: 65, col: 1, offset: 1770}, expr: &actionExpr{ - pos: position{line: 65, col: 28, offset: 1764}, + pos: position{line: 65, col: 28, offset: 1797}, run: (*parser).callonMatchSelectorOp1, expr: &seqExpr{ - pos: position{line: 65, col: 28, offset: 1764}, + pos: position{line: 65, col: 28, offset: 1797}, exprs: []interface{}{ &labeledExpr{ - pos: position{line: 65, col: 28, offset: 1764}, + pos: position{line: 65, col: 28, offset: 1797}, label: "selector", expr: &ruleRefExpr{ - pos: position{line: 65, col: 37, offset: 1773}, + pos: position{line: 65, col: 37, offset: 1806}, name: "Selector", }, }, &labeledExpr{ - pos: position{line: 65, col: 46, offset: 1782}, + pos: position{line: 65, col: 46, offset: 1815}, label: "operator", expr: &choiceExpr{ - pos: position{line: 65, col: 56, offset: 1792}, + pos: position{line: 65, col: 56, offset: 1825}, alternatives: []interface{}{ &ruleRefExpr{ - pos: position{line: 65, col: 56, offset: 1792}, + pos: position{line: 65, col: 56, offset: 1825}, name: "MatchIsEmpty", }, &ruleRefExpr{ - pos: position{line: 65, col: 71, offset: 1807}, + pos: position{line: 65, col: 71, offset: 1840}, name: "MatchIsNotEmpty", }, }, @@ -509,46 +517,46 @@ var g = &grammar{ { name: "MatchValueOpSelector", displayName: "\"match\"", - pos: position{line: 69, col: 1, offset: 1940}, + pos: position{line: 69, col: 1, offset: 1973}, expr: &choiceExpr{ - pos: position{line: 69, col: 33, offset: 1972}, + pos: position{line: 69, col: 33, offset: 2005}, alternatives: []interface{}{ &actionExpr{ - pos: position{line: 69, col: 33, offset: 1972}, + pos: position{line: 69, col: 33, offset: 2005}, run: (*parser).callonMatchValueOpSelector2, expr: &seqExpr{ - pos: position{line: 69, col: 33, offset: 1972}, + pos: position{line: 69, col: 33, offset: 2005}, exprs: []interface{}{ &labeledExpr{ - pos: position{line: 69, col: 33, offset: 1972}, + pos: position{line: 69, col: 33, offset: 2005}, label: "value", expr: &ruleRefExpr{ - pos: position{line: 69, col: 39, offset: 1978}, + pos: position{line: 69, col: 39, offset: 2011}, name: "Value", }, }, &labeledExpr{ - pos: position{line: 69, col: 45, offset: 1984}, + pos: position{line: 69, col: 45, offset: 2017}, label: "operator", expr: &choiceExpr{ - pos: position{line: 69, col: 55, offset: 1994}, + pos: position{line: 69, col: 55, offset: 2027}, alternatives: []interface{}{ &ruleRefExpr{ - pos: position{line: 69, col: 55, offset: 1994}, + pos: position{line: 69, col: 55, offset: 2027}, name: "MatchIn", }, &ruleRefExpr{ - pos: position{line: 69, col: 65, offset: 2004}, + pos: position{line: 69, col: 65, offset: 2037}, name: "MatchNotIn", }, }, }, }, &labeledExpr{ - pos: position{line: 69, col: 77, offset: 2016}, + pos: position{line: 69, col: 77, offset: 2049}, label: "selector", expr: &ruleRefExpr{ - pos: position{line: 69, col: 86, offset: 2025}, + pos: position{line: 69, col: 86, offset: 2058}, name: "Selector", }, }, @@ -556,38 +564,38 @@ var g = &grammar{ }, }, &seqExpr{ - pos: position{line: 71, col: 5, offset: 2167}, + pos: position{line: 71, col: 5, offset: 2200}, exprs: []interface{}{ &ruleRefExpr{ - pos: position{line: 71, col: 5, offset: 2167}, + pos: position{line: 71, col: 5, offset: 2200}, name: "Value", }, &labeledExpr{ - pos: position{line: 71, col: 11, offset: 2173}, + pos: position{line: 71, col: 11, offset: 2206}, label: "operator", expr: &choiceExpr{ - pos: position{line: 71, col: 21, offset: 2183}, + pos: position{line: 71, col: 21, offset: 2216}, alternatives: []interface{}{ &ruleRefExpr{ - pos: position{line: 71, col: 21, offset: 2183}, + pos: position{line: 71, col: 21, offset: 2216}, name: "MatchIn", }, &ruleRefExpr{ - pos: position{line: 71, col: 31, offset: 2193}, + pos: position{line: 71, col: 31, offset: 2226}, name: "MatchNotIn", }, }, }, }, ¬Expr{ - pos: position{line: 71, col: 43, offset: 2205}, + pos: position{line: 71, col: 43, offset: 2238}, expr: &ruleRefExpr{ - pos: position{line: 71, col: 44, offset: 2206}, + pos: position{line: 71, col: 44, offset: 2239}, name: "Selector", }, }, &andCodeExpr{ - pos: position{line: 71, col: 53, offset: 2215}, + pos: position{line: 71, col: 53, offset: 2248}, run: (*parser).callonMatchValueOpSelector20, }, }, @@ -597,29 +605,29 @@ var g = &grammar{ }, { name: "MatchEqual", - pos: position{line: 75, col: 1, offset: 2269}, + pos: position{line: 75, col: 1, offset: 2302}, expr: &actionExpr{ - pos: position{line: 75, col: 15, offset: 2283}, + pos: position{line: 75, col: 15, offset: 2316}, run: (*parser).callonMatchEqual1, expr: &seqExpr{ - pos: position{line: 75, col: 15, offset: 2283}, + pos: position{line: 75, col: 15, offset: 2316}, exprs: []interface{}{ &zeroOrOneExpr{ - pos: position{line: 75, col: 15, offset: 2283}, + pos: position{line: 75, col: 15, offset: 2316}, expr: &ruleRefExpr{ - pos: position{line: 75, col: 15, offset: 2283}, + pos: position{line: 75, col: 15, offset: 2316}, name: "_", }, }, &litMatcher{ - pos: position{line: 75, col: 18, offset: 2286}, + pos: position{line: 75, col: 18, offset: 2319}, val: "==", ignoreCase: false, }, &zeroOrOneExpr{ - pos: position{line: 75, col: 23, offset: 2291}, + pos: position{line: 75, col: 23, offset: 2324}, expr: &ruleRefExpr{ - pos: position{line: 75, col: 23, offset: 2291}, + pos: position{line: 75, col: 23, offset: 2324}, name: "_", }, }, @@ -629,29 +637,29 @@ var g = &grammar{ }, { name: "MatchNotEqual", - pos: position{line: 78, col: 1, offset: 2324}, + pos: position{line: 78, col: 1, offset: 2357}, expr: &actionExpr{ - pos: position{line: 78, col: 18, offset: 2341}, + pos: position{line: 78, col: 18, offset: 2374}, run: (*parser).callonMatchNotEqual1, expr: &seqExpr{ - pos: position{line: 78, col: 18, offset: 2341}, + pos: position{line: 78, col: 18, offset: 2374}, exprs: []interface{}{ &zeroOrOneExpr{ - pos: position{line: 78, col: 18, offset: 2341}, + pos: position{line: 78, col: 18, offset: 2374}, expr: &ruleRefExpr{ - pos: position{line: 78, col: 18, offset: 2341}, + pos: position{line: 78, col: 18, offset: 2374}, name: "_", }, }, &litMatcher{ - pos: position{line: 78, col: 21, offset: 2344}, + pos: position{line: 78, col: 21, offset: 2377}, val: "!=", ignoreCase: false, }, &zeroOrOneExpr{ - pos: position{line: 78, col: 26, offset: 2349}, + pos: position{line: 78, col: 26, offset: 2382}, expr: &ruleRefExpr{ - pos: position{line: 78, col: 26, offset: 2349}, + pos: position{line: 78, col: 26, offset: 2382}, name: "_", }, }, @@ -661,28 +669,28 @@ var g = &grammar{ }, { name: "MatchIsEmpty", - pos: position{line: 81, col: 1, offset: 2385}, + pos: position{line: 81, col: 1, offset: 2418}, expr: &actionExpr{ - pos: position{line: 81, col: 17, offset: 2401}, + pos: position{line: 81, col: 17, offset: 2434}, run: (*parser).callonMatchIsEmpty1, expr: &seqExpr{ - pos: position{line: 81, col: 17, offset: 2401}, + pos: position{line: 81, col: 17, offset: 2434}, exprs: []interface{}{ &ruleRefExpr{ - pos: position{line: 81, col: 17, offset: 2401}, + pos: position{line: 81, col: 17, offset: 2434}, name: "_", }, &litMatcher{ - pos: position{line: 81, col: 19, offset: 2403}, + pos: position{line: 81, col: 19, offset: 2436}, val: "is", ignoreCase: false, }, &ruleRefExpr{ - pos: position{line: 81, col: 24, offset: 2408}, + pos: position{line: 81, col: 24, offset: 2441}, name: "_", }, &litMatcher{ - pos: position{line: 81, col: 26, offset: 2410}, + pos: position{line: 81, col: 26, offset: 2443}, val: "empty", ignoreCase: false, }, @@ -692,37 +700,37 @@ var g = &grammar{ }, { name: "MatchIsNotEmpty", - pos: position{line: 84, col: 1, offset: 2450}, + pos: position{line: 84, col: 1, offset: 2483}, expr: &actionExpr{ - pos: position{line: 84, col: 20, offset: 2469}, + pos: position{line: 84, col: 20, offset: 2502}, run: (*parser).callonMatchIsNotEmpty1, expr: &seqExpr{ - pos: position{line: 84, col: 20, offset: 2469}, + pos: position{line: 84, col: 20, offset: 2502}, exprs: []interface{}{ &ruleRefExpr{ - pos: position{line: 84, col: 20, offset: 2469}, + pos: position{line: 84, col: 20, offset: 2502}, name: "_", }, &litMatcher{ - pos: position{line: 84, col: 21, offset: 2470}, + pos: position{line: 84, col: 21, offset: 2503}, val: "is", ignoreCase: false, }, &ruleRefExpr{ - pos: position{line: 84, col: 26, offset: 2475}, + pos: position{line: 84, col: 26, offset: 2508}, name: "_", }, &litMatcher{ - pos: position{line: 84, col: 28, offset: 2477}, + pos: position{line: 84, col: 28, offset: 2510}, val: "not", ignoreCase: false, }, &ruleRefExpr{ - pos: position{line: 84, col: 34, offset: 2483}, + pos: position{line: 84, col: 34, offset: 2516}, name: "_", }, &litMatcher{ - pos: position{line: 84, col: 36, offset: 2485}, + pos: position{line: 84, col: 36, offset: 2518}, val: "empty", ignoreCase: false, }, @@ -732,24 +740,24 @@ var g = &grammar{ }, { name: "MatchIn", - pos: position{line: 87, col: 1, offset: 2528}, + pos: position{line: 87, col: 1, offset: 2561}, expr: &actionExpr{ - pos: position{line: 87, col: 12, offset: 2539}, + pos: position{line: 87, col: 12, offset: 2572}, run: (*parser).callonMatchIn1, expr: &seqExpr{ - pos: position{line: 87, col: 12, offset: 2539}, + pos: position{line: 87, col: 12, offset: 2572}, exprs: []interface{}{ &ruleRefExpr{ - pos: position{line: 87, col: 12, offset: 2539}, + pos: position{line: 87, col: 12, offset: 2572}, name: "_", }, &litMatcher{ - pos: position{line: 87, col: 14, offset: 2541}, + pos: position{line: 87, col: 14, offset: 2574}, val: "in", ignoreCase: false, }, &ruleRefExpr{ - pos: position{line: 87, col: 19, offset: 2546}, + pos: position{line: 87, col: 19, offset: 2579}, name: "_", }, }, @@ -758,33 +766,33 @@ var g = &grammar{ }, { name: "MatchNotIn", - pos: position{line: 90, col: 1, offset: 2575}, + pos: position{line: 90, col: 1, offset: 2608}, expr: &actionExpr{ - pos: position{line: 90, col: 15, offset: 2589}, + pos: position{line: 90, col: 15, offset: 2622}, run: (*parser).callonMatchNotIn1, expr: &seqExpr{ - pos: position{line: 90, col: 15, offset: 2589}, + pos: position{line: 90, col: 15, offset: 2622}, exprs: []interface{}{ &ruleRefExpr{ - pos: position{line: 90, col: 15, offset: 2589}, + pos: position{line: 90, col: 15, offset: 2622}, name: "_", }, &litMatcher{ - pos: position{line: 90, col: 17, offset: 2591}, + pos: position{line: 90, col: 17, offset: 2624}, val: "not", ignoreCase: false, }, &ruleRefExpr{ - pos: position{line: 90, col: 23, offset: 2597}, + pos: position{line: 90, col: 23, offset: 2630}, name: "_", }, &litMatcher{ - pos: position{line: 90, col: 25, offset: 2599}, + pos: position{line: 90, col: 25, offset: 2632}, val: "in", ignoreCase: false, }, &ruleRefExpr{ - pos: position{line: 90, col: 30, offset: 2604}, + pos: position{line: 90, col: 30, offset: 2637}, name: "_", }, }, @@ -793,24 +801,24 @@ var g = &grammar{ }, { name: "MatchContains", - pos: position{line: 93, col: 1, offset: 2636}, + pos: position{line: 93, col: 1, offset: 2669}, expr: &actionExpr{ - pos: position{line: 93, col: 18, offset: 2653}, + pos: position{line: 93, col: 18, offset: 2686}, run: (*parser).callonMatchContains1, expr: &seqExpr{ - pos: position{line: 93, col: 18, offset: 2653}, + pos: position{line: 93, col: 18, offset: 2686}, exprs: []interface{}{ &ruleRefExpr{ - pos: position{line: 93, col: 18, offset: 2653}, + pos: position{line: 93, col: 18, offset: 2686}, name: "_", }, &litMatcher{ - pos: position{line: 93, col: 20, offset: 2655}, + pos: position{line: 93, col: 20, offset: 2688}, val: "contains", ignoreCase: false, }, &ruleRefExpr{ - pos: position{line: 93, col: 31, offset: 2666}, + pos: position{line: 93, col: 31, offset: 2699}, name: "_", }, }, @@ -819,33 +827,94 @@ var g = &grammar{ }, { name: "MatchNotContains", - pos: position{line: 96, col: 1, offset: 2695}, + pos: position{line: 96, col: 1, offset: 2728}, expr: &actionExpr{ - pos: position{line: 96, col: 21, offset: 2715}, + pos: position{line: 96, col: 21, offset: 2748}, run: (*parser).callonMatchNotContains1, expr: &seqExpr{ - pos: position{line: 96, col: 21, offset: 2715}, + pos: position{line: 96, col: 21, offset: 2748}, exprs: []interface{}{ &ruleRefExpr{ - pos: position{line: 96, col: 21, offset: 2715}, + pos: position{line: 96, col: 21, offset: 2748}, name: "_", }, &litMatcher{ - pos: position{line: 96, col: 23, offset: 2717}, + pos: position{line: 96, col: 23, offset: 2750}, val: "not", ignoreCase: false, }, &ruleRefExpr{ - pos: position{line: 96, col: 29, offset: 2723}, + pos: position{line: 96, col: 29, offset: 2756}, name: "_", }, &litMatcher{ - pos: position{line: 96, col: 31, offset: 2725}, + pos: position{line: 96, col: 31, offset: 2758}, val: "contains", ignoreCase: false, }, &ruleRefExpr{ - pos: position{line: 96, col: 42, offset: 2736}, + pos: position{line: 96, col: 42, offset: 2769}, + name: "_", + }, + }, + }, + }, + }, + { + name: "MatchMatches", + pos: position{line: 99, col: 1, offset: 2801}, + expr: &actionExpr{ + pos: position{line: 99, col: 17, offset: 2817}, + run: (*parser).callonMatchMatches1, + expr: &seqExpr{ + pos: position{line: 99, col: 17, offset: 2817}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 99, col: 17, offset: 2817}, + name: "_", + }, + &litMatcher{ + pos: position{line: 99, col: 19, offset: 2819}, + val: "matches", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 99, col: 29, offset: 2829}, + name: "_", + }, + }, + }, + }, + }, + { + name: "MatchNotMatches", + pos: position{line: 102, col: 1, offset: 2863}, + expr: &actionExpr{ + pos: position{line: 102, col: 20, offset: 2882}, + run: (*parser).callonMatchNotMatches1, + expr: &seqExpr{ + pos: position{line: 102, col: 20, offset: 2882}, + exprs: []interface{}{ + &ruleRefExpr{ + pos: position{line: 102, col: 20, offset: 2882}, + name: "_", + }, + &litMatcher{ + pos: position{line: 102, col: 22, offset: 2884}, + val: "not", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 102, col: 28, offset: 2890}, + name: "_", + }, + &litMatcher{ + pos: position{line: 102, col: 30, offset: 2892}, + val: "matches", + ignoreCase: false, + }, + &ruleRefExpr{ + pos: position{line: 102, col: 40, offset: 2902}, name: "_", }, }, @@ -855,28 +924,28 @@ var g = &grammar{ { name: "Selector", displayName: "\"selector\"", - pos: position{line: 101, col: 1, offset: 2770}, + pos: position{line: 106, col: 1, offset: 2940}, expr: &actionExpr{ - pos: position{line: 101, col: 24, offset: 2793}, + pos: position{line: 106, col: 24, offset: 2963}, run: (*parser).callonSelector1, expr: &seqExpr{ - pos: position{line: 101, col: 24, offset: 2793}, + pos: position{line: 106, col: 24, offset: 2963}, exprs: []interface{}{ &labeledExpr{ - pos: position{line: 101, col: 24, offset: 2793}, + pos: position{line: 106, col: 24, offset: 2963}, label: "first", expr: &ruleRefExpr{ - pos: position{line: 101, col: 30, offset: 2799}, + pos: position{line: 106, col: 30, offset: 2969}, name: "Identifier", }, }, &labeledExpr{ - pos: position{line: 101, col: 41, offset: 2810}, + pos: position{line: 106, col: 41, offset: 2980}, label: "rest", expr: &zeroOrMoreExpr{ - pos: position{line: 101, col: 46, offset: 2815}, + pos: position{line: 106, col: 46, offset: 2985}, expr: &ruleRefExpr{ - pos: position{line: 101, col: 46, offset: 2815}, + pos: position{line: 106, col: 46, offset: 2985}, name: "SelectorOrIndex", }, }, @@ -887,24 +956,24 @@ var g = &grammar{ }, { name: "Identifier", - pos: position{line: 114, col: 1, offset: 3022}, + pos: position{line: 119, col: 1, offset: 3192}, expr: &actionExpr{ - pos: position{line: 114, col: 15, offset: 3036}, + pos: position{line: 119, col: 15, offset: 3206}, run: (*parser).callonIdentifier1, expr: &seqExpr{ - pos: position{line: 114, col: 15, offset: 3036}, + pos: position{line: 119, col: 15, offset: 3206}, exprs: []interface{}{ &charClassMatcher{ - pos: position{line: 114, col: 15, offset: 3036}, + pos: position{line: 119, col: 15, offset: 3206}, val: "[a-zA-Z]", ranges: []rune{'a', 'z', 'A', 'Z'}, ignoreCase: false, inverted: false, }, &zeroOrMoreExpr{ - pos: position{line: 114, col: 24, offset: 3045}, + pos: position{line: 119, col: 24, offset: 3215}, expr: &charClassMatcher{ - pos: position{line: 114, col: 24, offset: 3045}, + pos: position{line: 119, col: 24, offset: 3215}, val: "[a-zA-Z0-9_]", chars: []rune{'_'}, ranges: []rune{'a', 'z', 'A', 'Z', '0', '9'}, @@ -918,26 +987,26 @@ var g = &grammar{ }, { name: "SelectorOrIndex", - pos: position{line: 118, col: 1, offset: 3094}, + pos: position{line: 123, col: 1, offset: 3264}, expr: &choiceExpr{ - pos: position{line: 118, col: 20, offset: 3113}, + pos: position{line: 123, col: 20, offset: 3283}, alternatives: []interface{}{ &actionExpr{ - pos: position{line: 118, col: 20, offset: 3113}, + pos: position{line: 123, col: 20, offset: 3283}, run: (*parser).callonSelectorOrIndex2, expr: &seqExpr{ - pos: position{line: 118, col: 20, offset: 3113}, + pos: position{line: 123, col: 20, offset: 3283}, exprs: []interface{}{ &litMatcher{ - pos: position{line: 118, col: 20, offset: 3113}, + pos: position{line: 123, col: 20, offset: 3283}, val: ".", ignoreCase: false, }, &labeledExpr{ - pos: position{line: 118, col: 24, offset: 3117}, + pos: position{line: 123, col: 24, offset: 3287}, label: "ident", expr: &ruleRefExpr{ - pos: position{line: 118, col: 30, offset: 3123}, + pos: position{line: 123, col: 30, offset: 3293}, name: "Identifier", }, }, @@ -945,13 +1014,13 @@ var g = &grammar{ }, }, &actionExpr{ - pos: position{line: 120, col: 5, offset: 3161}, + pos: position{line: 125, col: 5, offset: 3331}, run: (*parser).callonSelectorOrIndex7, expr: &labeledExpr{ - pos: position{line: 120, col: 5, offset: 3161}, + pos: position{line: 125, col: 5, offset: 3331}, label: "expr", expr: &ruleRefExpr{ - pos: position{line: 120, col: 10, offset: 3166}, + pos: position{line: 125, col: 10, offset: 3336}, name: "IndexExpression", }, }, @@ -962,45 +1031,45 @@ var g = &grammar{ { name: "IndexExpression", displayName: "\"index\"", - pos: position{line: 124, col: 1, offset: 3207}, + pos: position{line: 129, col: 1, offset: 3377}, expr: &choiceExpr{ - pos: position{line: 124, col: 28, offset: 3234}, + pos: position{line: 129, col: 28, offset: 3404}, alternatives: []interface{}{ &actionExpr{ - pos: position{line: 124, col: 28, offset: 3234}, + pos: position{line: 129, col: 28, offset: 3404}, run: (*parser).callonIndexExpression2, expr: &seqExpr{ - pos: position{line: 124, col: 28, offset: 3234}, + pos: position{line: 129, col: 28, offset: 3404}, exprs: []interface{}{ &litMatcher{ - pos: position{line: 124, col: 28, offset: 3234}, + pos: position{line: 129, col: 28, offset: 3404}, val: "[", ignoreCase: false, }, &zeroOrOneExpr{ - pos: position{line: 124, col: 32, offset: 3238}, + pos: position{line: 129, col: 32, offset: 3408}, expr: &ruleRefExpr{ - pos: position{line: 124, col: 32, offset: 3238}, + pos: position{line: 129, col: 32, offset: 3408}, name: "_", }, }, &labeledExpr{ - pos: position{line: 124, col: 35, offset: 3241}, + pos: position{line: 129, col: 35, offset: 3411}, label: "lit", expr: &ruleRefExpr{ - pos: position{line: 124, col: 39, offset: 3245}, + pos: position{line: 129, col: 39, offset: 3415}, name: "StringLiteral", }, }, &zeroOrOneExpr{ - pos: position{line: 124, col: 53, offset: 3259}, + pos: position{line: 129, col: 53, offset: 3429}, expr: &ruleRefExpr{ - pos: position{line: 124, col: 53, offset: 3259}, + pos: position{line: 129, col: 53, offset: 3429}, name: "_", }, }, &litMatcher{ - pos: position{line: 124, col: 56, offset: 3262}, + pos: position{line: 129, col: 56, offset: 3432}, val: "]", ignoreCase: false, }, @@ -1008,69 +1077,69 @@ var g = &grammar{ }, }, &seqExpr{ - pos: position{line: 126, col: 5, offset: 3291}, + pos: position{line: 131, col: 5, offset: 3461}, exprs: []interface{}{ &litMatcher{ - pos: position{line: 126, col: 5, offset: 3291}, + pos: position{line: 131, col: 5, offset: 3461}, val: "[", ignoreCase: false, }, &zeroOrOneExpr{ - pos: position{line: 126, col: 9, offset: 3295}, + pos: position{line: 131, col: 9, offset: 3465}, expr: &ruleRefExpr{ - pos: position{line: 126, col: 9, offset: 3295}, + pos: position{line: 131, col: 9, offset: 3465}, name: "_", }, }, ¬Expr{ - pos: position{line: 126, col: 12, offset: 3298}, + pos: position{line: 131, col: 12, offset: 3468}, expr: &ruleRefExpr{ - pos: position{line: 126, col: 13, offset: 3299}, + pos: position{line: 131, col: 13, offset: 3469}, name: "StringLiteral", }, }, &andCodeExpr{ - pos: position{line: 126, col: 27, offset: 3313}, + pos: position{line: 131, col: 27, offset: 3483}, run: (*parser).callonIndexExpression18, }, }, }, &seqExpr{ - pos: position{line: 128, col: 5, offset: 3365}, + pos: position{line: 133, col: 5, offset: 3535}, exprs: []interface{}{ &litMatcher{ - pos: position{line: 128, col: 5, offset: 3365}, + pos: position{line: 133, col: 5, offset: 3535}, val: "[", ignoreCase: false, }, &zeroOrOneExpr{ - pos: position{line: 128, col: 9, offset: 3369}, + pos: position{line: 133, col: 9, offset: 3539}, expr: &ruleRefExpr{ - pos: position{line: 128, col: 9, offset: 3369}, + pos: position{line: 133, col: 9, offset: 3539}, name: "_", }, }, &ruleRefExpr{ - pos: position{line: 128, col: 12, offset: 3372}, + pos: position{line: 133, col: 12, offset: 3542}, name: "StringLiteral", }, &zeroOrOneExpr{ - pos: position{line: 128, col: 26, offset: 3386}, + pos: position{line: 133, col: 26, offset: 3556}, expr: &ruleRefExpr{ - pos: position{line: 128, col: 26, offset: 3386}, + pos: position{line: 133, col: 26, offset: 3556}, name: "_", }, }, ¬Expr{ - pos: position{line: 128, col: 29, offset: 3389}, + pos: position{line: 133, col: 29, offset: 3559}, expr: &litMatcher{ - pos: position{line: 128, col: 30, offset: 3390}, + pos: position{line: 133, col: 30, offset: 3560}, val: "]", ignoreCase: false, }, }, &andCodeExpr{ - pos: position{line: 128, col: 34, offset: 3394}, + pos: position{line: 133, col: 34, offset: 3564}, run: (*parser).callonIndexExpression28, }, }, @@ -1081,42 +1150,42 @@ var g = &grammar{ { name: "Value", displayName: "\"value\"", - pos: position{line: 132, col: 1, offset: 3457}, + pos: position{line: 137, col: 1, offset: 3627}, expr: &choiceExpr{ - pos: position{line: 132, col: 18, offset: 3474}, + pos: position{line: 137, col: 18, offset: 3644}, alternatives: []interface{}{ &actionExpr{ - pos: position{line: 132, col: 18, offset: 3474}, + pos: position{line: 137, col: 18, offset: 3644}, run: (*parser).callonValue2, expr: &labeledExpr{ - pos: position{line: 132, col: 18, offset: 3474}, + pos: position{line: 137, col: 18, offset: 3644}, label: "selector", expr: &ruleRefExpr{ - pos: position{line: 132, col: 27, offset: 3483}, + pos: position{line: 137, col: 27, offset: 3653}, name: "Selector", }, }, }, &actionExpr{ - pos: position{line: 133, col: 10, offset: 3573}, + pos: position{line: 138, col: 10, offset: 3743}, run: (*parser).callonValue5, expr: &labeledExpr{ - pos: position{line: 133, col: 10, offset: 3573}, + pos: position{line: 138, col: 10, offset: 3743}, label: "n", expr: &ruleRefExpr{ - pos: position{line: 133, col: 12, offset: 3575}, + pos: position{line: 138, col: 12, offset: 3745}, name: "NumberLiteral", }, }, }, &actionExpr{ - pos: position{line: 134, col: 10, offset: 3643}, + pos: position{line: 139, col: 10, offset: 3813}, run: (*parser).callonValue8, expr: &labeledExpr{ - pos: position{line: 134, col: 10, offset: 3643}, + pos: position{line: 139, col: 10, offset: 3813}, label: "s", expr: &ruleRefExpr{ - pos: position{line: 134, col: 12, offset: 3645}, + pos: position{line: 139, col: 12, offset: 3815}, name: "StringLiteral", }, }, @@ -1127,32 +1196,32 @@ var g = &grammar{ { name: "NumberLiteral", displayName: "\"number\"", - pos: position{line: 136, col: 1, offset: 3704}, + pos: position{line: 141, col: 1, offset: 3874}, expr: &choiceExpr{ - pos: position{line: 136, col: 27, offset: 3730}, + pos: position{line: 141, col: 27, offset: 3900}, alternatives: []interface{}{ &actionExpr{ - pos: position{line: 136, col: 27, offset: 3730}, + pos: position{line: 141, col: 27, offset: 3900}, run: (*parser).callonNumberLiteral2, expr: &seqExpr{ - pos: position{line: 136, col: 27, offset: 3730}, + pos: position{line: 141, col: 27, offset: 3900}, exprs: []interface{}{ &zeroOrOneExpr{ - pos: position{line: 136, col: 27, offset: 3730}, + pos: position{line: 141, col: 27, offset: 3900}, expr: &litMatcher{ - pos: position{line: 136, col: 27, offset: 3730}, + pos: position{line: 141, col: 27, offset: 3900}, val: "-", ignoreCase: false, }, }, &ruleRefExpr{ - pos: position{line: 136, col: 32, offset: 3735}, + pos: position{line: 141, col: 32, offset: 3905}, name: "IntegerOrFloat", }, &andExpr{ - pos: position{line: 136, col: 47, offset: 3750}, + pos: position{line: 141, col: 47, offset: 3920}, expr: &ruleRefExpr{ - pos: position{line: 136, col: 48, offset: 3751}, + pos: position{line: 141, col: 48, offset: 3921}, name: "AfterNumbers", }, }, @@ -1160,29 +1229,29 @@ var g = &grammar{ }, }, &seqExpr{ - pos: position{line: 138, col: 5, offset: 3800}, + pos: position{line: 143, col: 5, offset: 3970}, exprs: []interface{}{ &zeroOrOneExpr{ - pos: position{line: 138, col: 5, offset: 3800}, + pos: position{line: 143, col: 5, offset: 3970}, expr: &litMatcher{ - pos: position{line: 138, col: 5, offset: 3800}, + pos: position{line: 143, col: 5, offset: 3970}, val: "-", ignoreCase: false, }, }, &ruleRefExpr{ - pos: position{line: 138, col: 10, offset: 3805}, + pos: position{line: 143, col: 10, offset: 3975}, name: "IntegerOrFloat", }, ¬Expr{ - pos: position{line: 138, col: 25, offset: 3820}, + pos: position{line: 143, col: 25, offset: 3990}, expr: &ruleRefExpr{ - pos: position{line: 138, col: 26, offset: 3821}, + pos: position{line: 143, col: 26, offset: 3991}, name: "AfterNumbers", }, }, &andCodeExpr{ - pos: position{line: 138, col: 39, offset: 3834}, + pos: position{line: 143, col: 39, offset: 4004}, run: (*parser).callonNumberLiteral15, }, }, @@ -1192,22 +1261,22 @@ var g = &grammar{ }, { name: "AfterNumbers", - pos: position{line: 142, col: 1, offset: 3894}, + pos: position{line: 147, col: 1, offset: 4064}, expr: &andExpr{ - pos: position{line: 142, col: 17, offset: 3910}, + pos: position{line: 147, col: 17, offset: 4080}, expr: &choiceExpr{ - pos: position{line: 142, col: 19, offset: 3912}, + pos: position{line: 147, col: 19, offset: 4082}, alternatives: []interface{}{ &ruleRefExpr{ - pos: position{line: 142, col: 19, offset: 3912}, + pos: position{line: 147, col: 19, offset: 4082}, name: "_", }, &ruleRefExpr{ - pos: position{line: 142, col: 23, offset: 3916}, + pos: position{line: 147, col: 23, offset: 4086}, name: "EOF", }, &litMatcher{ - pos: position{line: 142, col: 29, offset: 3922}, + pos: position{line: 147, col: 29, offset: 4092}, val: ")", ignoreCase: false, }, @@ -1217,32 +1286,32 @@ var g = &grammar{ }, { name: "IntegerOrFloat", - pos: position{line: 144, col: 1, offset: 3928}, + pos: position{line: 149, col: 1, offset: 4098}, expr: &seqExpr{ - pos: position{line: 144, col: 19, offset: 3946}, + pos: position{line: 149, col: 19, offset: 4116}, exprs: []interface{}{ &choiceExpr{ - pos: position{line: 144, col: 20, offset: 3947}, + pos: position{line: 149, col: 20, offset: 4117}, alternatives: []interface{}{ &litMatcher{ - pos: position{line: 144, col: 20, offset: 3947}, + pos: position{line: 149, col: 20, offset: 4117}, val: "0", ignoreCase: false, }, &seqExpr{ - pos: position{line: 144, col: 26, offset: 3953}, + pos: position{line: 149, col: 26, offset: 4123}, exprs: []interface{}{ &charClassMatcher{ - pos: position{line: 144, col: 26, offset: 3953}, + pos: position{line: 149, col: 26, offset: 4123}, val: "[1-9]", ranges: []rune{'1', '9'}, ignoreCase: false, inverted: false, }, &zeroOrMoreExpr{ - pos: position{line: 144, col: 31, offset: 3958}, + pos: position{line: 149, col: 31, offset: 4128}, expr: &charClassMatcher{ - pos: position{line: 144, col: 31, offset: 3958}, + pos: position{line: 149, col: 31, offset: 4128}, val: "[0-9]", ranges: []rune{'0', '9'}, ignoreCase: false, @@ -1254,19 +1323,19 @@ var g = &grammar{ }, }, &zeroOrOneExpr{ - pos: position{line: 144, col: 39, offset: 3966}, + pos: position{line: 149, col: 39, offset: 4136}, expr: &seqExpr{ - pos: position{line: 144, col: 40, offset: 3967}, + pos: position{line: 149, col: 40, offset: 4137}, exprs: []interface{}{ &litMatcher{ - pos: position{line: 144, col: 40, offset: 3967}, + pos: position{line: 149, col: 40, offset: 4137}, val: ".", ignoreCase: false, }, &oneOrMoreExpr{ - pos: position{line: 144, col: 44, offset: 3971}, + pos: position{line: 149, col: 44, offset: 4141}, expr: &charClassMatcher{ - pos: position{line: 144, col: 44, offset: 3971}, + pos: position{line: 149, col: 44, offset: 4141}, val: "[0-9]", ranges: []rune{'0', '9'}, ignoreCase: false, @@ -1282,55 +1351,55 @@ var g = &grammar{ { name: "StringLiteral", displayName: "\"string\"", - pos: position{line: 146, col: 1, offset: 3981}, + pos: position{line: 151, col: 1, offset: 4151}, expr: &choiceExpr{ - pos: position{line: 146, col: 27, offset: 4007}, + pos: position{line: 151, col: 27, offset: 4177}, alternatives: []interface{}{ &actionExpr{ - pos: position{line: 146, col: 27, offset: 4007}, + pos: position{line: 151, col: 27, offset: 4177}, run: (*parser).callonStringLiteral2, expr: &choiceExpr{ - pos: position{line: 146, col: 28, offset: 4008}, + pos: position{line: 151, col: 28, offset: 4178}, alternatives: []interface{}{ &seqExpr{ - pos: position{line: 146, col: 28, offset: 4008}, + pos: position{line: 151, col: 28, offset: 4178}, exprs: []interface{}{ &litMatcher{ - pos: position{line: 146, col: 28, offset: 4008}, + pos: position{line: 151, col: 28, offset: 4178}, val: "`", ignoreCase: false, }, &zeroOrMoreExpr{ - pos: position{line: 146, col: 32, offset: 4012}, + pos: position{line: 151, col: 32, offset: 4182}, expr: &ruleRefExpr{ - pos: position{line: 146, col: 32, offset: 4012}, + pos: position{line: 151, col: 32, offset: 4182}, name: "RawStringChar", }, }, &litMatcher{ - pos: position{line: 146, col: 47, offset: 4027}, + pos: position{line: 151, col: 47, offset: 4197}, val: "`", ignoreCase: false, }, }, }, &seqExpr{ - pos: position{line: 146, col: 53, offset: 4033}, + pos: position{line: 151, col: 53, offset: 4203}, exprs: []interface{}{ &litMatcher{ - pos: position{line: 146, col: 53, offset: 4033}, + pos: position{line: 151, col: 53, offset: 4203}, val: "\"", ignoreCase: false, }, &zeroOrMoreExpr{ - pos: position{line: 146, col: 57, offset: 4037}, + pos: position{line: 151, col: 57, offset: 4207}, expr: &ruleRefExpr{ - pos: position{line: 146, col: 57, offset: 4037}, + pos: position{line: 151, col: 57, offset: 4207}, name: "DoubleStringChar", }, }, &litMatcher{ - pos: position{line: 146, col: 75, offset: 4055}, + pos: position{line: 151, col: 75, offset: 4225}, val: "\"", ignoreCase: false, }, @@ -1340,40 +1409,40 @@ var g = &grammar{ }, }, &seqExpr{ - pos: position{line: 148, col: 5, offset: 4107}, + pos: position{line: 153, col: 5, offset: 4277}, exprs: []interface{}{ &choiceExpr{ - pos: position{line: 148, col: 6, offset: 4108}, + pos: position{line: 153, col: 6, offset: 4278}, alternatives: []interface{}{ &seqExpr{ - pos: position{line: 148, col: 6, offset: 4108}, + pos: position{line: 153, col: 6, offset: 4278}, exprs: []interface{}{ &litMatcher{ - pos: position{line: 148, col: 6, offset: 4108}, + pos: position{line: 153, col: 6, offset: 4278}, val: "`", ignoreCase: false, }, &zeroOrMoreExpr{ - pos: position{line: 148, col: 10, offset: 4112}, + pos: position{line: 153, col: 10, offset: 4282}, expr: &ruleRefExpr{ - pos: position{line: 148, col: 10, offset: 4112}, + pos: position{line: 153, col: 10, offset: 4282}, name: "RawStringChar", }, }, }, }, &seqExpr{ - pos: position{line: 148, col: 27, offset: 4129}, + pos: position{line: 153, col: 27, offset: 4299}, exprs: []interface{}{ &litMatcher{ - pos: position{line: 148, col: 27, offset: 4129}, + pos: position{line: 153, col: 27, offset: 4299}, val: "\"", ignoreCase: false, }, &zeroOrMoreExpr{ - pos: position{line: 148, col: 31, offset: 4133}, + pos: position{line: 153, col: 31, offset: 4303}, expr: &ruleRefExpr{ - pos: position{line: 148, col: 31, offset: 4133}, + pos: position{line: 153, col: 31, offset: 4303}, name: "DoubleStringChar", }, }, @@ -1382,11 +1451,11 @@ var g = &grammar{ }, }, &ruleRefExpr{ - pos: position{line: 148, col: 50, offset: 4152}, + pos: position{line: 153, col: 50, offset: 4322}, name: "EOF", }, &andCodeExpr{ - pos: position{line: 148, col: 54, offset: 4156}, + pos: position{line: 153, col: 54, offset: 4326}, run: (*parser).callonStringLiteral25, }, }, @@ -1396,40 +1465,40 @@ var g = &grammar{ }, { name: "RawStringChar", - pos: position{line: 152, col: 1, offset: 4220}, + pos: position{line: 157, col: 1, offset: 4390}, expr: &seqExpr{ - pos: position{line: 152, col: 18, offset: 4237}, + pos: position{line: 157, col: 18, offset: 4407}, exprs: []interface{}{ ¬Expr{ - pos: position{line: 152, col: 18, offset: 4237}, + pos: position{line: 157, col: 18, offset: 4407}, expr: &litMatcher{ - pos: position{line: 152, col: 19, offset: 4238}, + pos: position{line: 157, col: 19, offset: 4408}, val: "`", ignoreCase: false, }, }, &anyMatcher{ - line: 152, col: 23, offset: 4242, + line: 157, col: 23, offset: 4412, }, }, }, }, { name: "DoubleStringChar", - pos: position{line: 153, col: 1, offset: 4244}, + pos: position{line: 158, col: 1, offset: 4414}, expr: &seqExpr{ - pos: position{line: 153, col: 21, offset: 4264}, + pos: position{line: 158, col: 21, offset: 4434}, exprs: []interface{}{ ¬Expr{ - pos: position{line: 153, col: 21, offset: 4264}, + pos: position{line: 158, col: 21, offset: 4434}, expr: &litMatcher{ - pos: position{line: 153, col: 22, offset: 4265}, + pos: position{line: 158, col: 22, offset: 4435}, val: "\"", ignoreCase: false, }, }, &anyMatcher{ - line: 153, col: 26, offset: 4269, + line: 158, col: 26, offset: 4439, }, }, }, @@ -1437,11 +1506,11 @@ var g = &grammar{ { name: "_", displayName: "\"whitespace\"", - pos: position{line: 155, col: 1, offset: 4272}, + pos: position{line: 160, col: 1, offset: 4442}, expr: &oneOrMoreExpr{ - pos: position{line: 155, col: 19, offset: 4290}, + pos: position{line: 160, col: 19, offset: 4460}, expr: &charClassMatcher{ - pos: position{line: 155, col: 19, offset: 4290}, + pos: position{line: 160, col: 19, offset: 4460}, val: "[ \\t\\r\\n]", chars: []rune{' ', '\t', '\r', '\n'}, ignoreCase: false, @@ -1451,11 +1520,11 @@ var g = &grammar{ }, { name: "EOF", - pos: position{line: 157, col: 1, offset: 4302}, + pos: position{line: 162, col: 1, offset: 4472}, expr: ¬Expr{ - pos: position{line: 157, col: 8, offset: 4309}, + pos: position{line: 162, col: 8, offset: 4479}, expr: &anyMatcher{ - line: 157, col: 9, offset: 4310, + line: 162, col: 9, offset: 4480, }, }, }, @@ -1709,6 +1778,26 @@ func (p *parser) callonMatchNotContains1() (interface{}, error) { return p.cur.onMatchNotContains1() } +func (c *current) onMatchMatches1() (interface{}, error) { + return MatchMatches, nil +} + +func (p *parser) callonMatchMatches1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onMatchMatches1() +} + +func (c *current) onMatchNotMatches1() (interface{}, error) { + return MatchNotMatches, nil +} + +func (p *parser) callonMatchNotMatches1() (interface{}, error) { + stack := p.vstack[len(p.vstack)-1] + _ = stack + return p.cur.onMatchNotMatches1() +} + func (c *current) onSelector1(first, rest interface{}) (interface{}, error) { sel := Selector{ first.(string), diff --git a/vendor/github.com/hashicorp/go-bexpr/grammar.peg b/vendor/github.com/hashicorp/go-bexpr/grammar.peg index 99221fb7256f..21339f70ce4a 100644 --- a/vendor/github.com/hashicorp/go-bexpr/grammar.peg +++ b/vendor/github.com/hashicorp/go-bexpr/grammar.peg @@ -58,7 +58,7 @@ ParenthesizedExpression "grouping" <- "(" _? expr:OrExpression _? ")" { MatchExpression "match" <- MatchSelectorOpValue / MatchSelectorOp / MatchValueOpSelector -MatchSelectorOpValue "match" <- selector:Selector operator:(MatchEqual / MatchNotEqual / MatchContains / MatchNotContains) value:Value { +MatchSelectorOpValue "match" <- selector:Selector operator:(MatchEqual / MatchNotEqual / MatchContains / MatchNotContains / MatchMatches / MatchNotMatches) value:Value { return &MatchExpression{Selector: selector.(Selector), Operator: operator.(MatchOperator), Value: value.(*MatchValue)}, nil } @@ -96,7 +96,12 @@ MatchContains <- _ "contains" _ { MatchNotContains <- _ "not" _ "contains" _ { return MatchNotIn, nil } - +MatchMatches <- _ "matches" _ { + return MatchMatches, nil +} +MatchNotMatches <- _ "not" _ "matches" _ { + return MatchNotMatches, nil +} Selector "selector" <- first:Identifier rest:SelectorOrIndex* { sel := Selector{ diff --git a/vendor/github.com/hashicorp/go-bexpr/validate.go b/vendor/github.com/hashicorp/go-bexpr/validate.go index 8141544ffb69..abd6126789ea 100644 --- a/vendor/github.com/hashicorp/go-bexpr/validate.go +++ b/vendor/github.com/hashicorp/go-bexpr/validate.go @@ -2,6 +2,7 @@ package bexpr import ( "fmt" + "regexp" ) func validateRecurse(ast Expression, fields FieldConfigurations, maxRawValueLength int) (int, error) { @@ -96,6 +97,24 @@ func validateRecurse(ast Expression, fields FieldConfigurations, maxRawValueLeng node.Value.Converted = coerced } + + if node.Operator == MatchMatches || node.Operator == MatchNotMatches { + var regRaw string + if strVal, ok := node.Value.Converted.(string); ok { + regRaw = strVal + } else if node.Value.Converted == nil { + regRaw = node.Value.Raw + } else { + return 1, fmt.Errorf("Match operator %q cannot be used with fields whose coercion functions return non string values", node.Operator) + } + + re, err := regexp.Compile(regRaw) + if err != nil { + return 1, fmt.Errorf("Failed to compile regular expression %q: %v", regRaw, err) + } + + node.Value.Converted = re + } } else { switch node.Operator { case MatchIsEmpty, MatchIsNotEmpty: diff --git a/vendor/modules.txt b/vendor/modules.txt index 416437b3b3e9..f5812bd89070 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -194,7 +194,7 @@ github.com/gregjones/httpcache/diskcache github.com/hailocab/go-hostpool # github.com/hashicorp/errwrap v1.0.0 github.com/hashicorp/errwrap -# github.com/hashicorp/go-bexpr v0.1.0 +# github.com/hashicorp/go-bexpr v0.1.1 github.com/hashicorp/go-bexpr # github.com/hashicorp/go-checkpoint v0.0.0-20171009173528-1545e56e46de github.com/hashicorp/go-checkpoint diff --git a/website/source/api/agent/check.html.md b/website/source/api/agent/check.html.md index a5ad23a5e40d..7e9778b28a22 100644 --- a/website/source/api/agent/check.html.md +++ b/website/source/api/agent/check.html.md @@ -73,17 +73,17 @@ The filter will be executed against each health check value in the results map w the following selectors and filter operations being supported: -| Selector | Supported Operations | -| ------------- | ---------------------------------- | -| `CheckID` | Equal, Not Equal | -| `Name` | Equal, Not Equal | -| `Node` | Equal, Not Equal | -| `Notes` | Equal, Not Equal | -| `Output` | Equal, Not Equal | -| `ServiceID` | Equal, Not Equal | -| `ServiceName` | Equal, Not Equal | -| `ServiceTags` | In, Not In, Is Empty, Is Not Empty | -| `Status` | Equal, Not Equal | +| Selector | Supported Operations | +| ------------- | ------------------------------------------------- | +| `CheckID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Name` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Node` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Notes` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Output` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceName` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceTags` | In, Not In, Is Empty, Is Not Empty | +| `Status` | Equal, Not Equal, In, Not In, Matches, Not Matches | ## Register Check diff --git a/website/source/api/agent/service.html.md b/website/source/api/agent/service.html.md index 598264ed0d0c..b78d8cb511a5 100644 --- a/website/source/api/agent/service.html.md +++ b/website/source/api/agent/service.html.md @@ -87,34 +87,36 @@ $ curl \ The filter is executed against each value in the service mapping with the following selectors and filter operations being supported: -| Selector | Supported Operations | -| -------------------------------------- | ---------------------------------- | -| `Address` | Equal, Not Equal | -| `Connect.Native` | Equal, Not Equal | -| `EnableTagOverride` | Equal, Not Equal | -| `ID` | Equal, Not Equal | -| `Kind` | Equal, Not Equal | -| `Meta` | In, Not In, Is Empty, Is Not Empty | -| `Meta.` | Equal, Not Equal | -| `Port` | Equal, Not Equal | -| `Proxy.DestinationServiceID` | Equal, Not Equal | -| `Proxy.DestinationServiceName` | Equal, Not Equal | -| `Proxy.LocalServiceAddress` | Equal, Not Equal | -| `Proxy.LocalServicePort` | Equal, Not Equal | -| `Proxy.Upstreams` | Is Empty, Is Not Empty | -| `Proxy.Upstreams.Datacenter` | Equal, Not Equal | -| `Proxy.Upstreams.DestinationName` | Equal, Not Equal | -| `Proxy.Upstreams.DestinationNamespace` | Equal, Not Equal | -| `Proxy.Upstreams.DestinationType` | Equal, Not Equal | -| `Proxy.Upstreams.LocalBindAddress` | Equal, Not Equal | -| `Proxy.Upstreams.LocalBindPort` | Equal, Not Equal | -| `Service` | Equal, Not Equal | -| `TaggedAddresses` | In, Not In, Is Empty, Is Not Empty | -| `TaggedAddresses..Address` | Equal, Not Equal | -| `TaggedAddresses..Port` | Equal, Not Equal | -| `Tags` | In, Not In, Is Empty, Is Not Empty | -| `Weights.Passing` | Equal, Not Equal | -| `Weights.Warning` | Equal, Not Equal | +| Selector | Supported Operations | +| -------------------------------------- | ------------------------------------------------- | +| `Address` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Connect.Native` | Equal, Not Equal | +| `EnableTagOverride` | Equal, Not Equal | +| `ID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Kind` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Meta` | Is Empty, Is Not Empty, In, Not In | +| `Meta.` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Port` | Equal, Not Equal | +| `Proxy.DestinationServiceID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Proxy.DestinationServiceName` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Proxy.LocalServiceAddress` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Proxy.LocalServicePort` | Equal, Not Equal | +| `Proxy.MeshGateway.Mode` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Proxy.Upstreams` | Is Empty, Is Not Empty | +| `Proxy.Upstreams.Datacenter` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Proxy.Upstreams.DestinationName` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Proxy.Upstreams.DestinationNamespace` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Proxy.Upstreams.DestinationType` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Proxy.Upstreams.LocalBindAddress` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Proxy.Upstreams.LocalBindPort` | Equal, Not Equal | +| `Proxy.Upstreams.MeshGateway.Mode` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `TaggedAddresses` | Is Empty, Is Not Empty, In, Not In | +| `TaggedAddresses..Address` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `TaggedAddresses..Port` | Equal, Not Equal | +| `Tags` | In, Not In, Is Empty, Is Not Empty | +| `Weights.Passing` | Equal, Not Equal | +| `Weights.Warning` | Equal, Not Equal | ## Get Service Configuration diff --git a/website/source/api/catalog.html.md b/website/source/api/catalog.html.md index 1bc7ef0e017c..88618471dbb6 100644 --- a/website/source/api/catalog.html.md +++ b/website/source/api/catalog.html.md @@ -344,16 +344,16 @@ $ curl \ The filter will be executed against each Node in the result list with the following selectors and filter operations being supported: -| Selector | Supported Operations | -| ----------------------- | ---------------------------------- | -| `Address` | Equal, Not Equal | -| `Datacenter` | Equal, Not Equal | -| `ID` | Equal, Not Equal | -| `Meta` | In, Not In, Is Empty, Is Not Empty | -| `Meta.` | Equal, Not Equal | -| `Node` | Equal, Not Equal | -| `TaggedAddresses` | In, Not In, Is Empty, Is Not Empty | -| `TaggedAddresses.` | Equal, Not Equal | +| Selector | Supported Operations | +| ----------------------- | -------------------------------------------------- | +| `Address` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Datacenter` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Meta` | Is Empty, Is Not Empty, In, Not In | +| `Meta.` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Node` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `TaggedAddresses` | Is Empty, Is Not Empty, In, Not In | +| `TaggedAddresses.` | Equal, Not Equal, In, Not In, Matches, Not Matches | ## List Services @@ -571,42 +571,44 @@ $ curl \ Filtering is executed against each entry in the top level result list with the following selectors and filter operations being supported: -| Selector | Supported Operations | -| --------------------------------------------- | ---------------------------------- | -| `Address` | Equal, Not Equal | -| `Datacenter` | Equal, Not Equal | -| `ID` | Equal, Not Equal | -| `Node` | Equal, Not Equal | -| `NodeMeta` | In, Not In, Is Empty, Is Not Empty | -| `NodeMeta.` | Equal, Not Equal | -| `ServiceAddress` | Equal, Not Equal | -| `ServiceConnect.Native` | Equal, Not Equal | -| `ServiceEnableTagOverride` | Equal, Not Equal | -| `ServiceID` | Equal, Not Equal | -| `ServiceKind` | Equal, Not Equal | -| `ServiceMeta` | In, Not In, Is Empty, Is Not Empty | -| `ServiceMeta.` | Equal, Not Equal | -| `ServiceName` | Equal, Not Equal | -| `ServicePort` | Equal, Not Equal | -| `ServiceProxy.DestinationServiceID` | Equal, Not Equal | -| `ServiceProxy.DestinationServiceName` | Equal, Not Equal | -| `ServiceProxy.LocalServiceAddress` | Equal, Not Equal | -| `ServiceProxy.LocalServicePort` | Equal, Not Equal | -| `ServiceProxy.Upstreams` | Is Empty, Is Not Empty | -| `ServiceProxy.Upstreams.Datacenter` | Equal, Not Equal | -| `ServiceProxy.Upstreams.DestinationName` | Equal, Not Equal | -| `ServiceProxy.Upstreams.DestinationNamespace` | Equal, Not Equal | -| `ServiceProxy.Upstreams.DestinationType` | Equal, Not Equal | -| `ServiceProxy.Upstreams.LocalBindAddress` | Equal, Not Equal | -| `ServiceProxy.Upstreams.LocalBindPort` | Equal, Not Equal | -| `ServiceTaggedAddresses` | In, Not In, Is Empty, Is Not Empty | -| `ServiceTaggedAddresses..Address` | Equal, Not Equal | -| `ServiceTaggedAddresses..Port` | Equal, Not Equal | -| `ServiceTags` | In, Not In, Is Empty, Is Not Empty | -| `ServiceWeights.Passing` | Equal, Not Equal | -| `ServiceWeights.Warning` | Equal, Not Equal | -| `TaggedAddresses` | In, Not In, Is Empty, Is Not Empty | -| `TaggedAddresses.` | Equal, Not Equal | +| Selector | Supported Operations | +| --------------------------------------------- | ------------------------------------------------- | +| `Address` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Datacenter` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Node` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `NodeMeta.` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `NodeMeta` | Is Empty, Is Not Empty, In, Not In | +| `ServiceAddress` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceConnect.Native` | Equal, Not Equal | +| `ServiceEnableTagOverride` | Equal, Not Equal | +| `ServiceID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceKind` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceMeta.` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceMeta` | Is Empty, Is Not Empty, In, Not In | +| `ServiceName` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServicePort` | Equal, Not Equal | +| `ServiceProxy.DestinationServiceID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceProxy.DestinationServiceName` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceProxy.LocalServiceAddress` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceProxy.LocalServicePort` | Equal, Not Equal | +| `ServiceProxy.MeshGateway.Mode` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceProxy.Upstreams.Datacenter` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceProxy.Upstreams.DestinationName` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceProxy.Upstreams.DestinationNamespace` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceProxy.Upstreams.DestinationType` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceProxy.Upstreams.LocalBindAddress` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceProxy.Upstreams.LocalBindPort` | Equal, Not Equal | +| `ServiceProxy.Upstreams.MeshGateway.Mode` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceProxy.Upstreams` | Is Empty, Is Not Empty | +| `ServiceTaggedAddresses..Address` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceTaggedAddresses..Port` | Equal, Not Equal | +| `ServiceTaggedAddresses` | Is Empty, Is Not Empty, In, Not In | +| `ServiceTags` | In, Not In, Is Empty, Is Not Empty | +| `ServiceWeights.Passing` | Equal, Not Equal | +| `ServiceWeights.Warning` | Equal, Not Equal | +| `TaggedAddresses.` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `TaggedAddresses` | Is Empty, Is Not Empty, In, Not In | ## List Nodes for Connect-capable Service @@ -715,31 +717,34 @@ $ curl \ The filter will be executed against each value in the `Services` mapping within the top level Node object. The following selectors and filter operations are supported: -| Selector | Supported Operations | -| -------------------------------------- | ---------------------------------- | -| `Address` | Equal, Not Equal | -| `Connect.Native` | Equal, Not Equal | -| `EnableTagOverride` | Equal, Not Equal | -| `ID` | Equal, Not Equal | -| `Kind` | Equal, Not Equal | -| `Meta` | In, Not In, Is Empty, Is Not Empty | -| `Meta.` | Equal, Not Equal | -| `Port` | Equal, Not Equal | -| `Proxy.DestinationServiceID` | Equal, Not Equal | -| `Proxy.DestinationServiceName` | Equal, Not Equal | -| `Proxy.LocalServiceAddress` | Equal, Not Equal | -| `Proxy.LocalServicePort` | Equal, Not Equal | -| `Proxy.Upstreams` | Is Empty, Is Not Empty | -| `Proxy.Upstreams.Datacenter` | Equal, Not Equal | -| `Proxy.Upstreams.DestinationName` | Equal, Not Equal | -| `Proxy.Upstreams.DestinationNamespace` | Equal, Not Equal | -| `Proxy.Upstreams.DestinationType` | Equal, Not Equal | -| `Proxy.Upstreams.LocalBindAddress` | Equal, Not Equal | -| `Proxy.Upstreams.LocalBindPort` | Equal, Not Equal | -| `Service` | Equal, Not Equal | -| `TaggedAddresses` | In, Not In, Is Empty, Is Not Empty | -| `TaggedAddresses..Address` | Equal, Not Equal | -| `TaggedAddresses..Port` | Equal, Not Equal | -| `Tags` | In, Not In, Is Empty, Is Not Empty | -| `Weights.Passing` | Equal, Not Equal | -| `Weights.Warning` | Equal, Not Equal | +| Selector | Supported Operations | +| -------------------------------------- | -------------------------------------------------- | +| `Address` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Connect.Native` | Equal, Not Equal | +| `EnableTagOverride` | Equal, Not Equal | +| `ID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Kind` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Meta` | Is Empty, Is Not Empty, In, Not In | +| `Meta.` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Port` | Equal, Not Equal | +| `Proxy.DestinationServiceID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Proxy.DestinationServiceName` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Proxy.LocalServiceAddress` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Proxy.LocalServicePort` | Equal, Not Equal | +| `Proxy.MeshGateway.Mode` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Proxy.Upstreams` | Is Empty, Is Not Empty | +| `Proxy.Upstreams.Datacenter` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Proxy.Upstreams.DestinationName` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Proxy.Upstreams.DestinationNamespace` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Proxy.Upstreams.DestinationType` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Proxy.Upstreams.LocalBindAddress` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Proxy.Upstreams.LocalBindPort` | Equal, Not Equal | +| `Proxy.Upstreams.MeshGateway.Mode` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `TaggedAddresses` | Is Empty, Is Not Empty, In, Not In | +| `TaggedAddresses..Address` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `TaggedAddresses..Port` | Equal, Not Equal | +| `Tags` | In, Not In, Is Empty, Is Not Empty | +| `Weights.Passing` | Equal, Not Equal | +| `Weights.Warning` | Equal, Not Equal | + diff --git a/website/source/api/features/filtering.html.md b/website/source/api/features/filtering.html.md index 16eaae30c284..32ec5290f5d6 100644 --- a/website/source/api/features/filtering.html.md +++ b/website/source/api/features/filtering.html.md @@ -78,11 +78,15 @@ those endpoints. is empty is not empty -// Contains checks +// Contains checks or Substring Matching in not in contains not contains + +// Regular Expression Matching + matches + not matches ``` ### Selectors diff --git a/website/source/api/health.html.md b/website/source/api/health.html.md index ac057469ef66..50510f9ef1b1 100644 --- a/website/source/api/health.html.md +++ b/website/source/api/health.html.md @@ -88,17 +88,17 @@ $ curl \ The filter will be executed against each health check in the results list with the following selectors and filter operations being supported: -| Selector | Supported Operations | -| ------------- | ---------------------------------- | -| `CheckID` | Equal, Not Equal | -| `Name` | Equal, Not Equal | -| `Node` | Equal, Not Equal | -| `Notes` | Equal, Not Equal | -| `Output` | Equal, Not Equal | -| `ServiceID` | Equal, Not Equal | -| `ServiceName` | Equal, Not Equal | -| `ServiceTags` | In, Not In, Is Empty, Is Not Empty | -| `Status` | Equal, Not Equal | +| Selector | Supported Operations | +| ------------- | -------------------------------------------------- | +| `CheckID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Name` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Node` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Notes` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Output` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceName` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceTags` | In, Not In, Is Empty, Is Not Empty | +| `Status` | Equal, Not Equal, In, Not In, Matches, Not Matches | ## List Checks for Service @@ -172,17 +172,17 @@ The filter will be executed against each health check in the results list with the following selectors and filter operations being supported: -| Selector | Supported Operations | -| ------------- | ---------------------------------- | -| `CheckID` | Equal, Not Equal | -| `Name` | Equal, Not Equal | -| `Node` | Equal, Not Equal | -| `Notes` | Equal, Not Equal | -| `Output` | Equal, Not Equal | -| `ServiceID` | Equal, Not Equal | -| `ServiceName` | Equal, Not Equal | -| `ServiceTags` | In, Not In, Is Empty, Is Not Empty | -| `Status` | Equal, Not Equal | +| Selector | Supported Operations | +| ------------- | -------------------------------------------------- | +| `CheckID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Name` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Node` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Notes` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Output` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceName` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceTags` | In, Not In, Is Empty, Is Not Empty | +| `Status` | Equal, Not Equal, In, Not In, Matches, Not Matches | ## List Nodes for Service @@ -317,52 +317,54 @@ $ curl \ The filter will be executed against each entry in the top level results list with the following selectors and filter operations being supported: -| Selector | Supported Operations | -| ---------------------------------------------- | ---------------------------------- | -| `Checks` | Is Empty, Is Not Empty | -| `Checks.CheckID` | Equal, Not Equal | -| `Checks.Name` | Equal, Not Equal | -| `Checks.Node` | Equal, Not Equal | -| `Checks.Notes` | Equal, Not Equal | -| `Checks.Output` | Equal, Not Equal | -| `Checks.ServiceID` | Equal, Not Equal | -| `Checks.ServiceName` | Equal, Not Equal | -| `Checks.ServiceTags` | In, Not In, Is Empty, Is Not Empty | -| `Checks.Status` | Equal, Not Equal | -| `Node.Address` | Equal, Not Equal | -| `Node.Datacenter` | Equal, Not Equal | -| `Node.ID` | Equal, Not Equal | -| `Node.Meta` | In, Not In, Is Empty, Is Not Empty | -| `Node.Meta.` | Equal, Not Equal | -| `Node.Node` | Equal, Not Equal | -| `Node.TaggedAddresses` | In, Not In, Is Empty, Is Not Empty | -| `Node.TaggedAddresses.` | Equal, Not Equal | -| `Service.Address` | Equal, Not Equal | -| `Service.Connect.Native` | Equal, Not Equal | -| `Service.EnableTagOverride` | Equal, Not Equal | -| `Service.ID` | Equal, Not Equal | -| `Service.Kind` | Equal, Not Equal | -| `Service.Meta` | In, Not In, Is Empty, Is Not Empty | -| `Service.Meta.` | Equal, Not Equal | -| `Service.Port` | Equal, Not Equal | -| `Service.Proxy.DestinationServiceID` | Equal, Not Equal | -| `Service.Proxy.DestinationServiceName` | Equal, Not Equal | -| `Service.Proxy.LocalServiceAddress` | Equal, Not Equal | -| `Service.Proxy.LocalServicePort` | Equal, Not Equal | -| `Service.Proxy.Upstreams` | Is Empty, Is Not Empty | -| `Service.Proxy.Upstreams.Datacenter` | Equal, Not Equal | -| `Service.Proxy.Upstreams.DestinationName` | Equal, Not Equal | -| `Service.Proxy.Upstreams.DestinationNamespace` | Equal, Not Equal | -| `Service.Proxy.Upstreams.DestinationType` | Equal, Not Equal | -| `Service.Proxy.Upstreams.LocalBindAddress` | Equal, Not Equal | -| `Service.Proxy.Upstreams.LocalBindPort` | Equal, Not Equal | -| `Service.Service` | Equal, Not Equal | -| `Service.TaggedAddresses` | In, Not In, Is Empty, Is Not Empty | -| `Service.TaggedAddresses..Address` | Equal, Not Equal | -| `Service.TaggedAddresses..Port` | Equal, Not Equal | -| `Service.Tags` | In, Not In, Is Empty, Is Not Empty | -| `Service.Weights.Passing` | Equal, Not Equal | -| `Service.Weights.Warning` | Equal, Not Equal | +| Selector | Supported Operations | +| ---------------------------------------------- | -------------------------------------------------- | +| `Checks` | Is Empty, Is Not Empty | +| `Checks.CheckID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Checks.Name` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Checks.Node` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Checks.Notes` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Checks.Output` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Checks.ServiceID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Checks.ServiceName` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Checks.ServiceTags` | In, Not In, Is Empty, Is Not Empty | +| `Checks.Status` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Node.Address` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Node.Datacenter` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Node.ID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Node.Meta` | Is Empty, Is Not Empty, In, Not In | +| `Node.Meta.` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Node.Node` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Node.TaggedAddresses` | Is Empty, Is Not Empty, In, Not In | +| `Node.TaggedAddresses.` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service.Address` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service.Connect.Native` | Equal, Not Equal | +| `Service.EnableTagOverride` | Equal, Not Equal | +| `Service.ID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service.Kind` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service.Meta` | Is Empty, Is Not Empty, In, Not In | +| `Service.Meta.` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service.Port` | Equal, Not Equal | +| `Service.Proxy.DestinationServiceID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service.Proxy.DestinationServiceName` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service.Proxy.LocalServiceAddress` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service.Proxy.LocalServicePort` | Equal, Not Equal | +| `Service.Proxy.MeshGateway.Mode` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service.Proxy.Upstreams` | Is Empty, Is Not Empty | +| `Service.Proxy.Upstreams.Datacenter` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service.Proxy.Upstreams.DestinationName` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service.Proxy.Upstreams.DestinationNamespace` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service.Proxy.Upstreams.DestinationType` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service.Proxy.Upstreams.LocalBindAddress` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service.Proxy.Upstreams.LocalBindPort` | Equal, Not Equal | +| `Service.Proxy.Upstreams.MeshGateway.Mode` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service.Service` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service.TaggedAddresses` | Is Empty, Is Not Empty, In, Not In | +| `Service.TaggedAddresses..Address` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Service.TaggedAddresses..Port` | Equal, Not Equal | +| `Service.Tags` | In, Not In, Is Empty, Is Not Empty | +| `Service.Weights.Passing` | Equal, Not Equal | +| `Service.Weights.Warning` | Equal, Not Equal | ## List Nodes for Connect-capable Service @@ -462,14 +464,14 @@ The filter will be executed against each health check in the results list with the following selectors and filter operations being supported: -| Selector | Supported Operations | -| ------------- | ---------------------------------- | -| `CheckID` | Equal, Not Equal | -| `Name` | Equal, Not Equal | -| `Node` | Equal, Not Equal | -| `Notes` | Equal, Not Equal | -| `Output` | Equal, Not Equal | -| `ServiceID` | Equal, Not Equal | -| `ServiceName` | Equal, Not Equal | -| `ServiceTags` | In, Not In, Is Empty, Is Not Empty | -| `Status` | Equal, Not Equal | +| Selector | Supported Operations | +| ------------- | -------------------------------------------------- | +| `CheckID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Name` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Node` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Notes` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `Output` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceID` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceName` | Equal, Not Equal, In, Not In, Matches, Not Matches | +| `ServiceTags` | In, Not In, Is Empty, Is Not Empty | +| `Status` | Equal, Not Equal, In, Not In, Matches, Not Matches | From 9dfc1ed4176b71d34a53fe22aba9adbcabc56765 Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Tue, 23 Jul 2019 13:42:32 -0400 Subject: [PATCH 2/2] Add the capability to auto-generate the filtering selector ops tables for our docs --- agent/structs/structs_filtering_test.go | 90 +++++++++++++++++-- go.mod | 2 +- go.sum | 2 + .../hashicorp/go-bexpr/field_config.go | 38 ++++++++ vendor/modules.txt | 2 +- 5 files changed, 127 insertions(+), 7 deletions(-) diff --git a/agent/structs/structs_filtering_test.go b/agent/structs/structs_filtering_test.go index 10ce3e280af4..ffd9342f209b 100644 --- a/agent/structs/structs_filtering_test.go +++ b/agent/structs/structs_filtering_test.go @@ -1,7 +1,12 @@ package structs import ( + "flag" "fmt" + "os" + "sort" + "strings" + "sync" "testing" "github.com/hashicorp/consul/api" @@ -10,7 +15,7 @@ import ( "github.com/stretchr/testify/require" ) -const dumpFieldConfig bool = false +var dumpFieldConfig = flag.Bool("dump-field-config", false, "generate field config dump file") /////////////////////////////////////////////////////////////////////////////// // @@ -538,18 +543,93 @@ func validateFieldConfigurations(t *testing.T, expected, actual bexpr.FieldConfi require.True(t, validateFieldConfigurationsRecurse(t, expected, actual, "")) } +type fieldDumper struct { + fp *os.File + lock sync.Mutex +} + +func newFieldDumper(t *testing.T, path string) *fieldDumper { + fp, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0660) + require.NoError(t, err) + + return &fieldDumper{fp: fp} +} + +func (d *fieldDumper) Close() { + d.fp.Close() +} + +func (d *fieldDumper) DumpFields(name string, fields bexpr.FieldConfigurations) { + if d == nil { + return + } + + selectorOps := make([][2]string, 0, 10) + // need at least 8 chars wide for "Selector" + maxSelectorLen := 8 + // need at least 20 chars wid for "Supported Operaitons" + maxOpsLen := 20 + + fields.Walk(func(path bexpr.FieldPath, conf *bexpr.FieldConfiguration) bool { + if len(conf.SupportedOperations) < 1 { + return true + } + + selector := path.String() + var ops []string + for _, op := range conf.SupportedOperations { + ops = append(ops, op.String()) + } + + opString := strings.Join(ops, ", ") + selLen := len(selector) + opsLen := len(opString) + + if selLen > maxSelectorLen { + maxSelectorLen = selLen + } + if opsLen > maxOpsLen { + maxOpsLen = opsLen + } + + selectorOps = append(selectorOps, [2]string{selector, opString}) + return true + }) + + sort.Slice(selectorOps, func(i, j int) bool { + return selectorOps[i][0] < selectorOps[j][0] + }) + + d.lock.Lock() + defer d.lock.Unlock() + + // this will print the header and the string form of the fields + fmt.Fprintf(d.fp, "===== %s =====\n%s\n\n", name, fields) + + fmt.Fprintf(d.fp, "| %-[1]*[2]s | %-[3]*[4]s |\n", maxSelectorLen, "Selector", maxOpsLen, "Supported Operations") + fmt.Fprintf(d.fp, "| %s | %s |\n", strings.Repeat("-", maxSelectorLen), strings.Repeat("-", maxOpsLen)) + for _, selOp := range selectorOps { + fmt.Fprintf(d.fp, "| %-[1]*[2]s | %-[3]*[4]s |\n", maxSelectorLen, selOp[0], maxOpsLen, selOp[1]) + } + fmt.Fprintf(d.fp, "\n") +} + func TestStructs_FilterFieldConfigurations(t *testing.T) { t.Parallel() + + var d *fieldDumper + if *dumpFieldConfig { + d = newFieldDumper(t, "filter_fields.txt") + defer d.Close() + } + for name, tcase := range fieldConfigTests { // capture these values in the closure name := name tcase := tcase t.Run(name, func(t *testing.T) { - t.Parallel() fields, err := bexpr.GenerateFieldConfigurations(tcase.dataType) - if dumpFieldConfig { - fmt.Printf("===== %s =====\n%s\n", name, fields) - } + d.DumpFields(name, fields) require.NoError(t, err) validateFieldConfigurations(t, tcase.expected, fields) }) diff --git a/go.mod b/go.mod index f1090b0dc454..7d6843dfb442 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,7 @@ require ( github.com/gotestyourself/gotestyourself v2.2.0+incompatible // indirect github.com/hashicorp/consul/api v1.1.0 github.com/hashicorp/consul/sdk v0.1.1 - github.com/hashicorp/go-bexpr v0.1.1 + github.com/hashicorp/go-bexpr v0.1.2 github.com/hashicorp/go-checkpoint v0.0.0-20171009173528-1545e56e46de github.com/hashicorp/go-cleanhttp v0.5.1 github.com/hashicorp/go-discover v0.0.0-20190403160810-22221edb15cd diff --git a/go.sum b/go.sum index fde3006098ee..e767f03732bc 100644 --- a/go.sum +++ b/go.sum @@ -145,6 +145,8 @@ github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/U github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-bexpr v0.1.1 h1:WvjUsC7elNIAwpFGj7tfqXocJDBQbep0Py9hSNmtrFk= github.com/hashicorp/go-bexpr v0.1.1/go.mod h1:ANbpTX1oAql27TZkKVeW8p1w8NTdnyzPe/0qqPCKohU= +github.com/hashicorp/go-bexpr v0.1.2 h1:ijMXI4qERbzxbCnkxmfUtwMyjrrk3y+Vt0MxojNCbBs= +github.com/hashicorp/go-bexpr v0.1.2/go.mod h1:ANbpTX1oAql27TZkKVeW8p1w8NTdnyzPe/0qqPCKohU= github.com/hashicorp/go-checkpoint v0.0.0-20171009173528-1545e56e46de h1:XDCSythtg8aWSRSO29uwhgh7b127fWr+m5SemqjSUL8= github.com/hashicorp/go-checkpoint v0.0.0-20171009173528-1545e56e46de/go.mod h1:xIwEieBHERyEvaeKF/TcHh1Hu+lxPM+n2vT1+g9I4m4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= diff --git a/vendor/github.com/hashicorp/go-bexpr/field_config.go b/vendor/github.com/hashicorp/go-bexpr/field_config.go index b2df4d6c2243..5072fdf97f5e 100644 --- a/vendor/github.com/hashicorp/go-bexpr/field_config.go +++ b/vendor/github.com/hashicorp/go-bexpr/field_config.go @@ -15,6 +15,22 @@ type FieldName string // Used to represent an arbitrary field name const FieldNameAny FieldName = "" +type FieldPath []FieldName + +func (path FieldPath) String() string { + var parts []string + + for _, part := range path { + if part == FieldNameAny { + parts = append(parts, "") + } else { + parts = append(parts, string(part)) + } + } + + return strings.Join(parts, ".") +} + // The FieldConfiguration struct represents how boolean expression // validation and preparation should work for the given field. A field // in this case is a single element of a selector. @@ -312,3 +328,25 @@ func (configs FieldConfigurations) String() string { configs.stringInternal(&builder, 0, "") return builder.String() } + +type FieldConfigurationWalkFn func(path FieldPath, config *FieldConfiguration) bool + +func (configs FieldConfigurations) walk(path FieldPath, walkFn FieldConfigurationWalkFn) bool { + for fieldName, fieldConfig := range configs { + newPath := append(path, fieldName) + + if !walkFn(newPath, fieldConfig) { + return false + } + + if !fieldConfig.SubFields.walk(newPath, walkFn) { + return false + } + } + + return true +} + +func (configs FieldConfigurations) Walk(walkFn FieldConfigurationWalkFn) bool { + return configs.walk(nil, walkFn) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index f5812bd89070..46c35af03d7a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -194,7 +194,7 @@ github.com/gregjones/httpcache/diskcache github.com/hailocab/go-hostpool # github.com/hashicorp/errwrap v1.0.0 github.com/hashicorp/errwrap -# github.com/hashicorp/go-bexpr v0.1.1 +# github.com/hashicorp/go-bexpr v0.1.2 github.com/hashicorp/go-bexpr # github.com/hashicorp/go-checkpoint v0.0.0-20171009173528-1545e56e46de github.com/hashicorp/go-checkpoint