Skip to content

Commit

Permalink
add echo audit middleware and devcontainer
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Mason <[email protected]>
  • Loading branch information
fishnix authored and JAORMX committed Mar 29, 2023
1 parent 68ddc9c commit 719e1ed
Show file tree
Hide file tree
Showing 16 changed files with 969 additions and 56 deletions.
23 changes: 23 additions & 0 deletions .devcontainer/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# cockroachdb container config
COCKROACH_INSECURE=true
COCKROACH_HOST=crdb:26257
COCKROACH_URL="postgresql://root@crdb:26257/load_balancer_api_dev?sslmode=disable"

# loadbalancerapi config
LOADBALANCERAPI_CRDB_URI="postgresql://root@crdb:26257/load_balancer_api_dev?sslmode=disable"
LOADBALANCERAPI_NATS_CREDS_FILE=".devcontainer/nsc/nkeys/creds/LOCAL/LBAAS/USER.creds"
LOADBALANCERAPI_NATS_URL="nats://nats:4222"

NATS_URL="nats://nats:4222"
NATS_CREDS="/tmp/user.creds"

NKEYS_PATH="/workspace/.devcontainer/nsc/nkeys"
NSC_HOME="/workspace/.devcontainer/nsc/nats"

# postgresql client config
PGHOST=crdb
PGPORT=26257
PGSSLMODE=disable
PGDATABASE=load_balancer_api_dev
PGUSER=root
PAGER="less -iMx4 -FXe"
6 changes: 6 additions & 0 deletions .devcontainer/.env.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Go config
GOBIN=/workspace/.go/bin
GOENV=/workspace/.devcontainer/.env.go
GOMODCACHE=/workspace/.go/pkg/mod
GOPATH=/workspace/.go
GOCACHE=/workspace/.go/cache/go-build
19 changes: 19 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM mcr.microsoft.com/vscode/devcontainers/go:0-1.20-bullseye

# [Optional] Uncomment this section to install additional OS packages.
RUN export DEBIAN_FRONTEND=noninteractive \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor > /usr/share/keyrings/yarn-archive-keyring.gpg \
&& apt-get install apt-transport-https --yes \
&& apt-get update \
&& apt-get -y install --no-install-recommends \
bash-completion \
uuid-runtime

USER vscode

RUN go install -v github.com/cweill/gotests/[email protected]

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1

WORKDIR /workspace
39 changes: 39 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Config reference, https://containers.dev/implementors/json_reference/
{
"name": "auditevent",
"dockerComposeFile":"docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspace",
"shutdownAction": "stopCompose",
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.gopath": "/go"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"2gua.rainbow-brackets",
"golang.Go",
"mutantdino.resourcemonitor",
"oderwat.indent-rainbow",
"ms-azuretools.vscode-docker",
"RemiMarche.cspell-tech",
"streetsidesoftware.code-spell-checker",
"netcorext.uuid-generator"
]
}
},

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
// "remoteEnv": {},
"features": {
"git": "latest"
}
}
27 changes: 27 additions & 0 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "3.9"

networks:
infradev:

services:
app:
build:
context: .
dockerfile: Dockerfile
args:
VARIANT: 1.20-bullseye
NODE_VERSION: "none"
command:
- .devcontainer/scripts/app-entrypoint.sh
env_file:
- .env
- .env.go
volumes:
- ..:/workspace
networks:
- infradev
# Port forwarded for local development with emacs tramp
# ports:
# - "127.0.0.1:2222:2222"
# Use "forwardPorts" in **devcontainer.json** to forward a port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
3 changes: 3 additions & 0 deletions .devcontainer/scripts/app-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

sleep infinity
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
coverage.out
.tools/
.vscode/
.go/
4 changes: 0 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ linters:
- bidichk
- bodyclose
- containedctx
- deadcode
- decorder
- depguard
- dogsled
Expand Down Expand Up @@ -51,7 +50,6 @@ linters:
- gosimple
- govet
- grouper
- ifshort
- importas
- ineffassign
- lll
Expand All @@ -71,7 +69,6 @@ linters:
- rowserrcheck
- sqlclosecheck
- staticcheck
- structcheck
- stylecheck
- tagliatelle
- tenv
Expand All @@ -81,7 +78,6 @@ linters:
- unconvert
- unparam
- unused
- varcheck
- wastedassign
- whitespace
# - contextcheck
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ GOOS=linux

# Utility settings
TOOLS_DIR := .tools
GOLANGCI_LINT_VERSION = v1.49.0
GOLANGCI_LINT_VERSION = v1.51.2

# Container build settings
CONTAINER_BUILD_CMD?=docker build
Expand All @@ -25,7 +25,7 @@ PHONY: test coverage lint golint clean vendor

test: | lint
@echo Running unit tests...
@go test -timeout 30s -cover -short -tags testtools ./...
@go test -timeout 30s -cover -short -tags testtools ./...

coverage:
@echo Generating coverage report...
Expand Down
8 changes: 6 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/go-logr/logr v1.2.3
github.com/go-logr/zapr v1.2.3
github.com/google/uuid v1.3.0
github.com/labstack/echo/v4 v4.10.2
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/common v0.42.0
github.com/spf13/cobra v1.6.1
Expand All @@ -30,7 +31,9 @@ require (
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/labstack/gommon v0.4.0 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
Expand All @@ -42,14 +45,15 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.9 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 719e1ed

Please sign in to comment.