This repository has been archived by the owner on Aug 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
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 #8 from pantheon-systems/vet
cleans up some code per vet rules, adds the common makefile subtree, removes kube deploy.
- Loading branch information
Showing
28 changed files
with
753 additions
and
225 deletions.
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 |
---|---|---|
@@ -1,10 +1,6 @@ | ||
FROM alpine | ||
FROM scratch | ||
ADD ca-certificates.crt /etc/ssl/certs/ | ||
|
||
|
||
COPY baryon / | ||
COPY deploy/baryon.sh /baryon.sh | ||
RUN chmod 755 /baryon.sh /baryon | ||
|
||
EXPOSE 8888 | ||
ENTRYPOINT exec /baryon.sh | ||
ENTRYPOINT ["/baryon", "-p 8888"] |
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 |
---|---|---|
@@ -1,85 +1,29 @@ | ||
GO15VENDOREXPERIMENT=1 | ||
APP=baryon | ||
FETCH_CA_CERT=true | ||
|
||
all: deps test build | ||
include scripts/make/common.mk | ||
include scripts/make/common-go.mk | ||
include scripts/make/common-docker.mk | ||
|
||
list: | ||
@make -rqp | awk -F':' '/^[a-zA-Z0-9][^$$#\/\t=]*:([^=]|$$)/ {split($$1,A,/ /);for(i in A)print A[i]}' | sort | uniq | ||
|
||
deps: gvt_install | ||
gvt rebuild | ||
|
||
test: | ||
go test | ||
|
||
cov: | ||
go get github.com/pierrre/gotestcover | ||
go get github.com/mattn/goveralls | ||
gotestcover -coverprofile=coverage.out $$(go list ./... | grep -v /vendor/) | ||
|
||
coveralls: cov | ||
goveralls -repotoken $$COVERALLS_TOKEN -service=circleci -coverprofile=coverage.out | ||
|
||
cov_html: cov | ||
go tool cover -html=coverage.out | ||
|
||
build: | ||
go build | ||
|
||
build_linux: | ||
GOOS=linux go build | ||
|
||
deploy: | ||
kubectl rolling-update $(APP) --poll-interval="500ms" --image=gcr.io/$(GOOGLE_PROJECT)/$(APP) | ||
|
||
force_pod_restart: | ||
kubectl get pod -l"app=baryon" --no-headers | awk '{print $$1}' | xargs kubectl delete pod | ||
|
||
cert: | ||
curl https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt -o ca-certificates.crt | ||
|
||
circle_deps: | ||
bash deploy/gce/gcloud-setup.sh | ||
bash deploy/install-go.sh | ||
|
||
update_secrets: | ||
kubectl replace -f deploy/gce/baryon-ssl.yml | ||
kubectl replace -f deploy/gce/baryon-secrets.yml | ||
|
||
update_rc: | ||
kubectl get rc/baryon && kubectl replace -f deploy/gce/baryon-rc.yml || kubectl create -f deploy/gce/baryon-rc.yml | ||
|
||
release_deps: | ||
go get github.com/aktau/github-release | ||
go get -u github.com/pantheon-systems/autotag | ||
|
||
release: release_deps | ||
release: TAG=$(shell autotag -n) | ||
release: _deps-release ## run a release (usually from CI) | ||
release: VERSION=$(shell autotag -n) | ||
release: | ||
@echo "Building release for $(TAG)" | ||
autotag | ||
GOOS=linux go build -o baryon-linux | ||
GOOS=darwin go build -o baryon-darwin | ||
GOOS=windows go build | ||
github-release release -u pantheon-systems -r baryon -t $(TAG) --draft | ||
github-release upload -u pantheon-systems -r baryon -n Linux -f baryon-linux -t $(TAG) | ||
github-release upload -u pantheon-systems -r baryon -n OSX -f baryon-darwin -t $(TAG) | ||
github-release upload -u pantheon-systems -r baryon -n Windows -f baryon.exe -t $(TAG) | ||
|
||
|
||
refresh_deps: gvt_install | ||
bash deploy/refresh.sh | ||
|
||
gvt_install: | ||
go get -u github.com/FiloSottile/gvt | ||
|
||
# gce task builds the docker container, and pushes it to gce container repo. | ||
# no reason this can't be quay.io | ||
# We pull down root certs, cause the docker image doesn't have them. | ||
gce: docker | ||
gcloud docker push gcr.io/$(GOOGLE_PROJECT)/$(APP) | ||
|
||
docker: cert build_linux | ||
docker build -t gcr.io/$(GOOGLE_PROJECT)/$(APP) . | ||
|
||
.PHONY: all | ||
@echo "Building release for $(VERSION)" | ||
CIRCLE_BUILD_NUM=$(VERSION) make push-circle | ||
autotag | ||
GOOS=linux go build -o baryon-linux | ||
GOOS=darwin go build -o baryon-darwin | ||
GOOS=windows go build | ||
github-release release -u pantheon-systems -r baryon -t $(VERSION) --draft | ||
github-release upload -u pantheon-systems -r baryon -n Linux -f baryon-linux -t $(VERSION) | ||
github-release upload -u pantheon-systems -r baryon -n OSX -f baryon-darwin -t $(VERSION) | ||
github-release upload -u pantheon-systems -r baryon -n Windows -f baryon.exe -t $(VERSION) | ||
|
||
_deps-release: # install tools needed for release, conditionally | ||
ifneq ("$(wildcard Dockerfile))","") | ||
go get github.com/aktau/github-release | ||
endif | ||
ifeq ($(shell which autotag)),) | ||
curl -L https://github.com/pantheon-systems/autotag/releases/download/v0.0.4/autotag.linux.x86_64 -o ~/bin/autotag | ||
chmod 755 ~/bin/autotag | ||
endif |
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
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,52 @@ | ||
build:: ## build project for current arch | ||
go build | ||
|
||
build-linux:: _fetch-cert ## build project for linux | ||
GOOS=linux CGO_ENABLED=0 go build -ldflags="-s -w" | ||
|
||
# if there is a docker file then set the docker variable so things can trigger off it | ||
build-docker:: ## build the docker container if the dockerfile exists | ||
ifeq ("$(wildcard $(CURDIR)/Dockerfile)","") | ||
$(error "Docker task called, but no DOCKER variable set. Eitehr Dockerfile is missing or you didn't include common.") | ||
else | ||
docker build -t $(IMAGE) . | ||
endif | ||
|
||
build-circle:: build-linux ## build project for linux. If you need docker you will have to invoke that with an extension | ||
|
||
deps:: _gvt-install ## install dependencies for project assumes you have go binary installed | ||
find ./vendor/* -maxdepth 0 -type d -exec rm -rf "{}" \; | ||
gvt rebuild | ||
|
||
test:: ## run go tests | ||
go test -race -v $$(go list ./... | grep -v /vendor/) | ||
|
||
test-circle:: test test-coveralls ## invoke test tasks for CI | ||
|
||
deps-circle:: ## install Golang and pull dependencies in CI | ||
bash scripts/make/sh/install-go.sh | ||
|
||
deps-coverage:: | ||
go get github.com/pierrre/gotestcover | ||
go get github.com/mattn/goveralls | ||
|
||
deps-status:: ## check status of deps with gostatus | ||
ifeq (, $(shell which gostatus)) | ||
go get -u github.com/shurcooL/gostatus | ||
endif | ||
go list -f '{{join .Deps "\n"}}' . | gostatus -stdin -v | ||
|
||
test-coveralls:: deps-coverage ## run coverage and report to coveralls | ||
gotestcover -v -race -coverprofile=coverage.out $$(go list ./... | grep -v /vendor/) | ||
goveralls -repotoken $$COVERALLS_TOKEN -service=circleci -coverprofile=coverage.out | ||
|
||
test-coverage-html:: deps-coverage ## output html coverage file | ||
go tool cover -html=coverage.html | ||
|
||
_gvt-install:: | ||
go get -u github.com/FiloSottile/gvt | ||
|
||
_fetch-cert:: | ||
ifdef $(FETCH_CA_CERT) | ||
curl https://curl.haxx.se/ca/cacert.pem -o ca-certificates.crt | ||
endif |
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,51 @@ | ||
REGISTRY ?= quay.io/getpantheon | ||
|
||
# determinse the docker tag to build | ||
ifeq ($(CIRCLE_BUILD_NUM),) | ||
BUILD_NUM := dev | ||
else | ||
BUILD_NUM := $(CIRCLE_BUILD_NUM) | ||
QUAY := docker login -p "$$QUAY_PASSWD" -u "$$QUAY_USER" -e "unused@unused" quay.io | ||
endif | ||
|
||
# If we have no circle branch, use development kube env | ||
# If we are on master branch, use production kube env | ||
# If we are NOT on master use testing kube env | ||
ifeq ($(CIRCLE_BRANCH),) # Dev | ||
KUBE_ENV := development | ||
else ifeq ($(CIRCLE_BRANCH), master) # prod | ||
KUBE_ENV := production | ||
else # testing | ||
KUBE_ENV := testing | ||
endif | ||
|
||
# These can be overridden | ||
IMAGE ?= $(REGISTRY)/$(APP):$(BUILD_NUM) | ||
SERVCE ?= $(APP) | ||
|
||
# debatable weather this should be in common or not, but I see it needed enough in dev. | ||
# TODO(jesse): possibly guard this to prevent accidentally nuking production. | ||
force-pod-restart:: ## nuke the pod | ||
kubectl --namespace=$(KUBE_ENV) get pod -l"app=$(APP)" --no-headers | awk '{print $$1}' | xargs kubectl delete pod | ||
|
||
push:: ## push the container to the registry | ||
docker push $(IMAGE) | ||
|
||
setup-quay:: ## setup docker login for quay.io | ||
ifndef $(QUAY_PASSWD) | ||
$(error "Need to set QUAY_PASSWD environment variable") | ||
endif | ||
ifndef $(QUAY_USER) | ||
$(error "Need to set QUAY_USER environment variable") | ||
endif | ||
$(QUAY) | ||
|
||
# we call make here to ensure new states are detected | ||
push-circle:: ## build and push the container from circle | ||
make build-docker | ||
psuh-circle:: setup-quay | ||
make push | ||
|
||
# extend or define circle deps to install gcloud | ||
deps-circle:: | ||
@bash scripts/make/sh/install-gcloud.sh |
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,12 @@ | ||
# common make tasks and variables that should be imported into all projects | ||
# | ||
#------------------------------------------------------------------------------- | ||
|
||
help: ## print list of tasks and descriptions | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?##"}; { split($$0,a,":"); printf "\033[36m%-30s\033[0m %s \n", a[2], $$2}' | ||
.DEFAULT_GOAL := help | ||
|
||
update-makefiles: ## update the make subtree, assumes the subtree is in scripts/make | ||
git subtree pull --prefix scripts/make common_makefiles master --squash | ||
|
||
.PHONY: all |
Oops, something went wrong.