Skip to content
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.

Commit

Permalink
Initial version (#1)
Browse files Browse the repository at this point in the history
Logs all POST requests to StdOut in JSON format
  • Loading branch information
aslakknutsen authored Sep 1, 2017
1 parent 791d734 commit ce51e7d
Show file tree
Hide file tree
Showing 17 changed files with 1,545 additions and 0 deletions.
87 changes: 87 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
### Intellij ###
.idea/
*.iws
*.iml
/out/
.idea_modules/
atlassian-ide-plugin.xml

### Eclipse ###
.metadata
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders

# Eclipse Core
.project

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# Code Recommenders
.recommenders/


### VisualStudioCode ###
.vscode

### Go ###
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so

# Folders
_obj
_test

# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out

*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*

_testmain.go

*.exe
*.test
*.prof

# F8 specific artifacts
/debug
**/debug.test

# F8 binaries
bin/

# Glide package manager
.glide
vendor/

# Generated assets
app/
assets/js/
bindata_assetfs.go
client/
swagger/
tool/cli/
migration/sqlbindata.go
template/bindata.go
wit/api

# Ignore artifacts directory
bin/

26 changes: 26 additions & 0 deletions .make/Makefile.lnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
BINARY_SERVER_BIN=$(INSTALL_PREFIX)/$(PROJECT_NAME)
GLIDE_BIN=glide
GOAGEN_BIN=$(VENDOR_DIR)/github.com/goadesign/goa/goagen/goagen
GO_BINDATA_BIN=$(VENDOR_DIR)/github.com/jteeuwen/go-bindata/go-bindata/go-bindata
GO_BINDATA_DIR=$(VENDOR_DIR)/github.com/jteeuwen/go-bindata/go-bindata/
GO_BINDATA_ASSETFS_BIN=$(VENDOR_DIR)/github.com/elazarl/go-bindata-assetfs/go-bindata-assetfs/go-bindata-assetfs
FRESH_BIN=$(VENDOR_DIR)/github.com/pilu/fresh/fresh
EXTRA_PATH=$(shell dirname $(GO_BINDATA_BIN))
GOCOV_BIN=$(VENDOR_DIR)/github.com/axw/gocov/gocov/gocov
GOCOVMERGE_BIN=$(VENDOR_DIR)/github.com/wadey/gocovmerge/gocovmerge
DOCKER_BIN_NAME=docker
DOCKER_COMPOSE_BIN_NAME=docker-compose

GOLINT_DIR=$(VENDOR_DIR)/github.com/golang/lint/golint
GOLINT_BIN=$(GOLINT_DIR)/golint
GOCYCLO_DIR=$(VENDOR_DIR)/github.com/fzipp/gocyclo
GOCYCLO_BIN=$(GOCYCLO_DIR)/gocyclo
GO_JUNIT_BIN=$(VENDOR_DIR)/github.com/jstemmer/go-junit-report/go-junit-report


GIT_BIN_NAME := git
GLIDE_BIN_NAME := glide
GO_BIN_NAME := go
HG_BIN_NAME := hg

CHECK_GOPATH_BIN := $(INSTALL_PREFIX)/check_gopath
25 changes: 25 additions & 0 deletions .make/Makefile.win
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
BINARY_SERVER_BIN=$(INSTALL_PREFIX)/$(PROJECT_NAME).exe
GLIDE_BIN=glide.exe
GOAGEN_BIN=$(VENDOR_DIR)/github.com/goadesign/goa/goagen/goagen.exe
GO_BINDATA_BIN=$(VENDOR_DIR)/github.com/jteeuwen/go-bindata/go-bindata/go-bindata.exe
GO_BINDATA_DIR=$(VENDOR_DIR)/github.com/jteeuwen/go-bindata/go-bindata/
GO_BINDATA_ASSETFS_BIN=$(VENDOR_DIR)/github.com/elazarl/go-bindata-assetfs/go-bindata-assetfs/go-bindata-assetfs.exe
FRESH_BIN=$(VENDOR_DIR)/github.com/pilu/fresh/fresh.exe
EXTRA_PATH=$(shell cygpath --unix '$(GO_BINDATA_DIR)')
GOCOV_BIN=$(VENDOR_DIR)/github.com/axw/gocov/gocov/gocov.exe
GOCOVMERGE_BIN=$(VENDOR_DIR)/github.com/wadey/gocovmerge/gocovmerge.exe
DOCKER_BIN_NAME=docker.exe
DOCKER_COMPOSE_BIN_NAME=docker-compose.exe

GOLINT_DIR=$(VENDOR_DIR)/github.com/golang/lint/golint
GOLINT_BIN=$(GOLINT_DIR)/golint.exe
GOCYCLO_DIR=$(VENDOR_DIR)/github.com/fzipp/gocyclo
GOCYCLO_BIN=$(GOCYCLO_DIR)/gocyclo.exe
GO_JUNIT_BIN=$(VENDOR_DIR)/github.com/jstemmer/go-junit-report/go-junit-report.exe

GIT_BIN_NAME := git.exe
GLIDE_BIN_NAME := glide.exe
GO_BIN_NAME := go.exe
HG_BIN_NAME := hg.exe

CHECK_GOPATH_BIN := $(INSTALL_PREFIX)/check_gopath.exe
39 changes: 39 additions & 0 deletions .make/check_gopath.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"flag"
"fmt"
"log"
"os"
"path/filepath"
"strings"
)

// Checks if the packageName is checked out into one of the GOPATH entries
// under GOPATH[i]/src/packageName.
func main() {
var packageName string
flag.StringVar(&packageName, "packageName", "github.com/fabric8-services/fabric8-notification", "Package Name (e.g.)")
flag.Parse()

wd, err := os.Getwd()
if err != nil {
log.Fatal(err)
}

for _, p := range strings.Split(os.Getenv("GOPATH"), string(filepath.ListSeparator)) {
// Check if p is a directory
if info, err := os.Stat(p); err == nil && info.IsDir() {
// Make sure we have an absolute path
abs, err := filepath.Abs(p)
if err != nil {
log.Fatal(err)
}
if wd == filepath.Join(abs, "src", packageName) {
os.Exit(0)
}
}
}

log.Fatal(fmt.Errorf("Make sure you've checked out your project in GOPATH/src/%s", packageName))
}
122 changes: 122 additions & 0 deletions .make/docker.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
DOCKER_IMAGE_CORE := $(PROJECT_NAME)
DOCKER_IMAGE_DEPLOY := $(PROJECT_NAME)-deploy

# If running in Jenkins we don't allow for interactively running the container
ifneq ($(BUILD_TAG),)
DOCKER_RUN_INTERACTIVE_SWITCH :=
else
DOCKER_RUN_INTERACTIVE_SWITCH := -i
endif

# The workspace environment is set by Jenkins and defaults to /tmp if not set
WORKSPACE ?= /tmp
DOCKER_BUILD_DIR := $(WORKSPACE)/$(PROJECT_NAME)-build

# The BUILD_TAG environment variable will be set by jenkins
# to reflect jenkins-${JOB_NAME}-${BUILD_NUMBER}
BUILD_TAG ?= $(PROJECT_NAME)-local-build
DOCKER_CONTAINER_NAME := $(BUILD_TAG)

# Where is the GOPATH inside the build container?
GOPATH_IN_CONTAINER=/tmp/go
PACKAGE_PATH=$(GOPATH_IN_CONTAINER)/src/$(PACKAGE_NAME)

.PHONY: docker-image-builder
## Builds the docker image used to build the software.
docker-image-builder:
@echo "Building docker image $(DOCKER_IMAGE_CORE)"
docker build -t $(DOCKER_IMAGE_CORE) -f $(CUR_DIR)/Dockerfile.builder $(CUR_DIR)

.PHONY: docker-image-deploy
## Creates a runnable image using the artifacts from the bin directory.
docker-image-deploy:
docker build -t $(DOCKER_IMAGE_DEPLOY) -f $(CUR_DIR)/Dockerfile.deploy $(CUR_DIR)

.PHONY: docker-publish-deploy
## Tags the runnable image and pushes it to the docker hub.
docker-publish-deploy:
docker tag $(DOCKER_IMAGE_DEPLOY) openshiftio/${PROJECT_NAME}:latest
docker push openshiftio/${PROJECT_NAME}:latest

.PHONY: docker-build-dir
## Creates the docker build directory.
docker-build-dir:
@echo "Creating build directory $(BUILD_DIR)"
mkdir -p $(DOCKER_BUILD_DIR)

CLEAN_TARGETS += clean-docker-build-container
.PHONY: clean-docker-build-container
## Removes any existing container used to build the software (if any).
clean-docker-build-container:
@echo "Removing container named \"$(DOCKER_CONTAINER_NAME)\" (if any)"
ifneq ($(strip $(shell docker ps -qa --filter "name=$(DOCKER_CONTAINER_NAME)" 2>/dev/null)),)
@docker rm -f $(DOCKER_CONTAINER_NAME)
else
@echo "No container named \"$(DOCKER_CONTAINER_NAME)\" to remove"
endif

CLEAN_TARGETS += clean-docker-build-dir
.PHONY: clean-docker-build-dir
## Removes the docker build directory.
clean-docker-build-dir:
@echo "Cleaning build directory $(BUILD_DIR)"
-rm -rf $(DOCKER_BUILD_DIR)

.PHONY: docker-start
## Starts the docker build container in the background (detached mode).
## After calling this command you can invoke all the make targets from the
## normal Makefile (e.g. deps, generate, build) inside the build container
## by prefixing them with "docker-". For example to execute "make deps"
## inside the build container, just run "make docker-deps".
## To remove the container when no longer needed, call "make docker-rm".
docker-start: docker-build-dir docker-image-builder
ifneq ($(strip $(shell docker ps -qa --filter "name=$(DOCKER_CONTAINER_NAME)" 2>/dev/null)),)
@echo "Docker container \"$(DOCKER_CONTAINER_NAME)\" already exists. To recreate, run \"make docker-rm\"."
else
docker run \
--detach=true \
-t \
$(DOCKER_RUN_INTERACTIVE_SWITCH) \
--name="$(DOCKER_CONTAINER_NAME)" \
-v $(CUR_DIR):$(PACKAGE_PATH):Z \
-u $(shell id -u $(USER)):$(shell id -g $(USER)) \
-e GOPATH=$(GOPATH_IN_CONTAINER) \
-w $(PACKAGE_PATH) \
$(DOCKER_IMAGE_CORE)
@echo "Docker container \"$(DOCKER_CONTAINER_NAME)\" created. Continue with \"make docker-deps\"."
endif

.PHONY: docker-rm
## Removes the docker build container, if any (see "make docker-start").
docker-rm:
ifneq ($(strip $(shell docker ps -qa --filter "name=$(DOCKER_CONTAINER_NAME)" 2>/dev/null)),)
docker rm -f "$(DOCKER_CONTAINER_NAME)"
else
@echo "No container named \"$(DOCKER_CONTAINER_NAME)\" to remove."
endif

# The targets in the following list all depend on a running database container.
# Make sure you run "make integration-test-env-prepare" before you run any of these targets.
DB_DEPENDENT_DOCKER_TARGETS = docker-test-migration docker-test-integration docker-test-integration-no-coverage docker-coverage-all

$(DB_DEPENDENT_DOCKER_TARGETS):
$(eval makecommand:=$(subst docker-,,$@))
ifeq ($(strip $(shell docker ps -qa --filter "name=$(DOCKER_CONTAINER_NAME)" 2>/dev/null)),)
$(error No container name "$(DOCKER_CONTAINER_NAME)" exists to run the build. Try running "make docker-start")
endif
ifeq ($(strip $(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' make_postgres_integration_test_1 2>/dev/null)),)
$(error Failed to find PostgreSQL container. Try running "make integration-test-env-prepare")
endif
$(eval F8_POSTGRES_HOST := $(shell docker inspect --format '{{ .NetworkSettings.IPAddress }}' make_postgres_integration_test_1 2>/dev/null))
docker exec -t $(DOCKER_RUN_INTERACTIVE_SWITCH) "$(DOCKER_CONTAINER_NAME)" bash -ec 'export F8_POSTGRES_HOST=$(F8_POSTGRES_HOST); export F8_POSTGRES_DATABASE=postgres; make $(makecommand)'

# This is a wildcard target to let you call any make target from the normal makefile
# but it will run inside the docker container. This target will only get executed if
# there's no specialized form available. For example if you call "make docker-start"
# not this target gets executed but the "docker-start" target.
docker-%:
$(eval makecommand:=$(subst docker-,,$@))
ifeq ($(strip $(shell docker ps -qa --filter "name=$(DOCKER_CONTAINER_NAME)" 2>/dev/null)),)
$(error No container name "$(DOCKER_CONTAINER_NAME)" exists to run the command "make $(makecommand)")
endif
docker exec -t $(DOCKER_RUN_INTERACTIVE_SWITCH) "$(DOCKER_CONTAINER_NAME)" bash -ec 'make $(makecommand)'
Loading

0 comments on commit ce51e7d

Please sign in to comment.