diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..18a97e6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +.env +bin +!bin/README.md +data/ +vendor/ +.vscode/ +pkg/**/**/test +cmd/**/**/test +internal/**/**/test +testdata/ +test/testdata/ +test/mock_* diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2649762 --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ +export RELEASE_VERSION ?= $(shell git describe --always) +export DOCKER_REGISTRY ?= registry.nordix.org/eiffel +export DEPLOY ?= goer + +all: test build start +gen: + go generate ./... +build: gen + go get github.com/ahmetb/govvv@v0.3.0 + govvv build -o bin/goer ./cmd/goer +clean: + rm ./bin/* || true + docker-compose --project-directory . -f deploy/$(DEPLOY)/docker-compose.yml rm || true + docker volume rm goer-volume || true +test: gen + go test -cover -timeout 30s -race $(shell go list ./... | grep -v test) + +# Start a development docker with a database that restarts on file changes. +start: + docker-compose --project-directory . -f deploy/$(DEPLOY)/docker-compose.yml up +stop: + docker-compose --project-directory . -f deploy/$(DEPLOY)/docker-compose.yml down + +# Build a docker using the production Dockerfile +docker: + docker build -t $(DOCKER_REGISTRY)/$(DEPLOY):$(RELEASE_VERSION) -f ./deploy/$(DEPLOY)/Dockerfile . +push: + docker push $(DOCKER_REGISTRY)/$(DEPLOY):$(RELEASE_VERSION) diff --git a/README.md b/README.md index c175d1e..0b0be57 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Eiffel Goer implements the event repository API and is intended as an open sourc ### Docker - docker run -e CONNECTION_STRING=yourdb -e DATABASE_NAME=dbname -e API_PORT=8080 registry.nordix.org/eiffel/goer + docker run -e CONNECTION_STRING=yourdb -e API_PORT=8080 registry.nordix.org/eiffel/goer ### Running a development server locally for testing. Will restart on code changes. diff --git a/api/openapi-spec.yaml b/api/openapi-spec.yaml new file mode 100644 index 0000000..059518b --- /dev/null +++ b/api/openapi-spec.yaml @@ -0,0 +1,473 @@ +openapi: 3.0.1 +info: + title: Event Repository REST API + description: Event Repository REST API for retrieving the event information + contact: {} + version: 0.0.1 +tags: +- name: event-resource + description: The Event Resource API for getting single event information +- name: search-resource + description: The search api provides methods for querying up/down stream given an + event id. +- name: events-resource + description: The Events Resource API for getting all events information +paths: + /events: + get: + tags: + - events-resource + summary: To get all events information + operationId: getEventsUsingGET + parameters: + - name: pageNo + in: query + description: "Page to display if results span across multiple pages." + schema: + type: integer + format: int32 + default: 1 + - name: pageSize + in: query + description: "The number of events to be displayed per page." + schema: + type: integer + format: int32 + default: 500 + - name: pageStartItem + in: query + description: "Intended to skip few items at the start of result, Should\ + \ be used only if `pageNo=1` ie. first page of results." + schema: + type: integer + format: int32 + default: 1 + - name: shallow + in: query + description: "Determines if external ER's should be used to compile\ + \ the results of query. Use `false` to use External ER's." + schema: + type: boolean + default: false + - name: lazy + in: query + description: "If lazy is `true`, it implies that when the events limit\ + \ is reached according to pazesize no additional request is performed and the search will stop." + schema: + type: boolean + default: false + - name: readable + in: query + description: | + Determines if event time should be in milliseconds, or in Human readable time format. Ex: + + `false` 1499076742982 + + `true` 2018-10-31T13:36:00.824Z. + schema: + type: boolean + default: false + - name: params + in: query + description: | + To search for specific events or artifacts, filtering with parameters is supported. + + **Syntax:** + + `?key[.key ...]value[&key[.key ...]value ...]` + + is one of the Filter comparators described below. To traverse into nested structures and filter on their keys, namespacing with + `.` (dot) is used. + + ``` + = - equal to + > - greater than + < - less than + >= - greater than or equal to + <= - less than or equal to + != - not equal to + ``` + + **Examples, single key:** + + `/events/?meta.type=EiffelActivityStartedEvent` + + **Examples multiple keys:** + + ``` + /events/?key1=value1&key2=value2 + /events/?key1>=value1&key2!=value2&key3value1&key1<=value2&key1!=value3 #Multiple constraints on one key + ``` + + **Examples nested structures:** + ``` + /events/?data.identity=pkg:maven/my.namespace/my-name@1.0.0 + /events/?meta.source.domainId=my.domain&data.identity=pkg:maven/my.namespace/my-name@1.0.0 #Multiple keys and nested structures + ``` + + Note that mutiple keys only is allowed with logical AND (via `&`). There are no support for logical OR. + + Filters also allow for regex to be used. This means you can make more complex matchings or use partial matching. In regex `.*` matches anything and basically works like wildcards. + + **Examples of regex:** + ``` + /events/?data.identity=my-artifact@1.0.0 #Partial match using artifact name and version + /events/?data.identity=my.namespace #Partial match using artifact namespace + /events/?data.identity=my.namespace/.*@1.0.0 #Matches any version 1.0.0 artifact within the namespace 'my.namespace' + /events/?data.identity=my.namespace/my-name@.* #Matches any version of the artifact 'my-artifact' within the namepsace 'my-namespace' + /events/?data.identity=my.namespace/.* #Matches any artifact within the namespace 'my.namespace' + ``` + **Data types:** + + By default, all data types are treated as strings. It is possible to specify the data type by including it explicitly in the query: + + ``` + /events/?int(key1)>=value1&key2!=value2&double(key3)