open-consul/vendor/github.com/hashicorp/go-bexpr/Makefile
Matt Keeler ac78c23021
Implement data filtering of some endpoints (#5579)
Fixes: #4222 

# Data Filtering

This PR will implement filtering for the following endpoints:

## Supported HTTP Endpoints

- `/agent/checks`
- `/agent/services`
- `/catalog/nodes`
- `/catalog/service/:service`
- `/catalog/connect/:service`
- `/catalog/node/:node`
- `/health/node/:node`
- `/health/checks/:service`
- `/health/service/:service`
- `/health/connect/:service`
- `/health/state/:state`
- `/internal/ui/nodes`
- `/internal/ui/services`

More can be added going forward and any endpoint which is used to list some data is a good candidate.

## Usage

When using the HTTP API a `filter` query parameter can be used to pass a filter expression to Consul. Filter Expressions take the general form of:

```
<selector> == <value>
<selector> != <value>
<value> in <selector>
<value> not in <selector>
<selector> contains <value>
<selector> not contains <value>
<selector> is empty
<selector> is not empty
not <other expression>
<expression 1> and <expression 2>
<expression 1> or <expression 2>
```

Normal boolean logic and precedence is supported. All of the actual filtering and evaluation logic is coming from the [go-bexpr](https://github.com/hashicorp/go-bexpr) library

## Other changes

Adding the `Internal.ServiceDump` RPC endpoint. This will allow the UI to filter services better.
2019-04-16 12:00:15 -04:00

65 lines
1.3 KiB
Makefile

GOTEST_PKGS=$(shell go list ./... | grep -v examples)
BENCHTIME ?= 2s
BENCHTESTS ?= .
BENCHFULL?=0
ifeq (${BENCHFULL},1)
BENCHFULL_ARG=-bench-full -timeout 60m
else
BENCHFULL_ARG=
endif
TEST_VERBOSE?=0
ifeq (${TEST_VERBOSE},1)
TEST_VERBOSE_ARG=-v
else
TEST_VERBOSE_ARG=
endif
TEST_RESULTS?="/tmp/test-results"
grammar.go: grammar.peg
@echo "Regenerating Parser"
@go generate ./
generate: grammar.go
test: generate
@go test $(TEST_VERBOSE_ARG) $(GOTEST_PKGS)
test-ci: generate
@gotestsum --junitfile $(TEST_RESULTS)/gotestsum-report.xml -- $(GOTEST_PKGS)
bench: generate
@go test $(TEST_VERBOSE_ARG) -run DONTRUNTESTS -bench $(BENCHTESTS) $(BENCHFULL_ARG) -benchtime=$(BENCHTIME) $(GOTEST_PKGS)
coverage: generate
@go test -coverprofile /tmp/coverage.out $(GOTEST_PKGS)
@go tool cover -html /tmp/coverage.out
fmt: generate
@gofmt -w -s
examples: simple expr-parse expr-eval filter
simple:
@go build ./examples/simple
expr-parse:
@go build ./examples/expr-parse
expr-eval:
@go build ./examples/expr-eval
filter:
@go build ./examples/filter
deps:
@go get github.com/mna/pigeon@master
@go get golang.org/x/tools/cmd/goimports
@go get golang.org/x/tools/cmd/cover
@go mod tidy
.PHONY: generate test coverage fmt deps bench examples expr-parse expr-eval filter