-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from VNG-Realisatie/feature/static-ref-api
Feature/static ref api
- Loading branch information
Showing
35 changed files
with
14,298 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
venv | ||
.idea | ||
.code | ||
Dockerfile | ||
Makefile | ||
dist | ||
__pycache__ | ||
.DS_Store | ||
.git | ||
README.md | ||
LICENCE.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- "master" | ||
tags: | ||
- "v*.*.*" | ||
- "*.*.*" | ||
|
||
jobs: | ||
push-images: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
# list of Docker images to use as base name for tags | ||
images: | | ||
ghcr.io/VNG-Realisatie/referentielijsten-api | ||
# generate Docker tags based on the following events/attributes | ||
tags: | | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=sha | ||
- | ||
name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
- | ||
name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_TOKEN }} | ||
- | ||
name: Log in to github | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GHCR_TOKEN }} | ||
|
||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
push: ${{ github.event_name != 'pull_request' }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Run tests with coverage | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test: | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.20.x | ||
|
||
- name: Download | ||
run: go mod download | ||
|
||
- name: Test | ||
run: go test -v -cover ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# If you prefer the allow list template instead of the deny list, see community template: | ||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore | ||
# | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# Go workspace file | ||
go.work | ||
|
||
#idea | ||
.idea | ||
.code | ||
|
||
/gen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# builder image | ||
FROM golang:1.20-alpine3.17 as build-env | ||
#STEP 1 build the image | ||
#RUN apk --no-cache add git | ||
ENV GO111MODULE=on | ||
RUN mkdir /app | ||
WORKDIR /app | ||
COPY go.mod . | ||
COPY go.sum . | ||
|
||
# Get dependenciesgo | ||
RUN go mod download | ||
# COPY the source code as the last step | ||
COPY . . | ||
RUN GO111MODULE=on GOOS=linux CGO_ENABLED=0 go build /app/main.go | ||
|
||
FROM alpine | ||
|
||
RUN apk update && apk add ca-certificates | ||
RUN rm -rf /var/cache/apk/* | ||
|
||
RUN mkdir /app | ||
WORKDIR / | ||
|
||
COPY --from=build-env /app/main /app/ | ||
RUN mv /app/main /app/referentielijsten | ||
|
||
COPY docs/openapi.yaml /app/docs/openapi.yaml | ||
COPY docs/redoc.html /app/docs/redoc.html | ||
|
||
ENV TMPDIR=/tmp | ||
ENV GOMAXPROCS=8 | ||
|
||
EXPOSE 8000 | ||
ENTRYPOINT [ "sh", "-c", "/app/referentielijsten" ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
ROOT_DIR=$(shell pwd) | ||
|
||
generate_swagger: | ||
docker run -it -v ${ROOT_DIR}:${ROOT_DIR} -e SWAGGER_GENERATE_EXTENSION=false --workdir ${ROOT_DIR} quay.io/goswagger/swagger generate spec -o ./docs/swagger.json -m; | ||
|
||
generate_openapi: | ||
curl -X 'POST' \ | ||
'https://converter.swagger.io/api/convert' \ | ||
-H 'accept: application/yaml' \ | ||
-H 'Content-Type: application/json' \ | ||
-d '@./docs/swagger.json' > docs/openapi.yaml | ||
|
||
generate_both: generate_swagger generate_openapi | ||
|
||
docker_build: | ||
docker build -t referentielijsten:new . | ||
|
||
docker_run: docker_delete | ||
docker run --name referentielijsten -p 8001:8000 -d referentielijsten:new | ||
|
||
docker_delete: | ||
docker rm -f referentielijsten |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/VNG-Realisatie/referentielijsten-api/api/v1" | ||
"github.com/VNG-Realisatie/referentielijsten-api/middleware" | ||
"github.com/VNG-Realisatie/referentielijsten-api/models" | ||
"github.com/gorilla/mux" | ||
) | ||
|
||
// InitRoutes to start up a mux router and return the routes | ||
func InitRoutes(loader *models.Loader) *mux.Router { | ||
serveMux := mux.NewRouter() | ||
|
||
v1Handler := v1.ReferentielijstenHandler{ | ||
Data: loader, | ||
} | ||
|
||
serveMux.HandleFunc("/api/v1/health", middleware.Adapt(v1Handler.Health, middleware.ValidateRestMethod("GET"), middleware.LogRequestDetails(), middleware.SetCorsHeaders())) | ||
|
||
//resultaten | ||
serveMux.HandleFunc("/api/v1/resultaten", middleware.Adapt(v1Handler.ListResultaten, middleware.ValidateRestMethod("GET"), middleware.LogRequestDetails(), middleware.SetCorsHeaders())) | ||
serveMux.HandleFunc("/api/v1/resultaten/{uuid}", middleware.Adapt(v1Handler.GetResultaat, middleware.ValidateRestMethod("GET"), middleware.LogRequestDetails(), middleware.SetCorsHeaders())) | ||
|
||
//resultaattypeomschrijvingen | ||
serveMux.HandleFunc("/api/v1/resultaattypeomschrijvingen", middleware.Adapt(v1Handler.ListResultaattypeomschrijvingen, middleware.ValidateRestMethod("GET"), middleware.LogRequestDetails(), middleware.SetCorsHeaders())) | ||
serveMux.HandleFunc("/api/v1/resultaattypeomschrijvingen/{uuid}", middleware.Adapt(v1Handler.GetResultaattypeomschrijving, middleware.ValidateRestMethod("GET"), middleware.LogRequestDetails(), middleware.SetCorsHeaders())) | ||
|
||
//procestypen | ||
serveMux.HandleFunc("/api/v1/procestypen", middleware.Adapt(v1Handler.ListProcesTypen, middleware.ValidateRestMethod("GET"), middleware.LogRequestDetails(), middleware.SetCorsHeaders())) | ||
serveMux.HandleFunc("/api/v1/procestypen/{uuid}", middleware.Adapt(v1Handler.GetProcesType, middleware.ValidateRestMethod("GET"), middleware.LogRequestDetails(), middleware.SetCorsHeaders())) | ||
|
||
//redoc | ||
serveMux.HandleFunc("/api/v1/schema", middleware.Adapt(serveRedoc, middleware.ValidateRestMethod("GET"), middleware.LogRequestDetails(), middleware.SetCorsHeaders())) | ||
serveMux.HandleFunc("/api/v1/openapi.yaml", middleware.Adapt(serveOpenApi, middleware.ValidateRestMethod("GET"), middleware.LogRequestDetails(), middleware.SetCorsHeaders())) | ||
|
||
return serveMux | ||
} |
Oops, something went wrong.