forked from openshift/ansible-service-broker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
92 lines (69 loc) · 2.84 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
REGISTRY ?= docker.io
ORG ?= ansibleplaybookbundle
TAG ?= latest
BROKER_IMAGE ?= $(REGISTRY)/$(ORG)/ansible-service-broker
BUILD_DIR = "${GOPATH}/src/github.com/openshift/ansible-service-broker/build"
PREFIX ?= /usr/local
BROKER_CONFIG ?= $(PWD)/etc/generated_local_development.yaml
SOURCE_DIRS = cmd pkg
SOURCES := $(shell find . -name '*.go' -not -path "*/vendor/*")
SVC_ACCT_DIR := /var/run/secrets/kubernetes.io/serviceaccount
KUBERNETES_FILES := $(addprefix $(SVC_ACCT_DIR)/,ca.crt token tls.crt tls.key)
.DEFAULT_GOAL := build
vendor: ## Install project dependencies
@glide install -v
broker: $(SOURCES) ## Build the broker
go build -i -ldflags="-s -w" ./cmd/broker
build: broker ## Build the project
@echo > /dev/null
lint: ## Run golint
@golint -set_exit_status $(addsuffix /... , $(SOURCE_DIRS))
fmt: ## Run go fmt
@gofmt -d $(SOURCES)
fmtcheck: ## Check go formatting
@gofmt -l $(SOURCES) | grep ".*\.go"; if [ "$$?" = "0" ]; then exit 1; fi
test: ## Run unit tests
@go test ./pkg/...
vet: ## Run go vet
@go tool vet ./cmd ./pkg
pre-flight: fmtcheck vet lint build test ## Pre-flight checks before creating PR
run: broker | $(KUBERNETES_FILES) ## Run the broker executable locally
@./scripts/run_local.sh ${BROKER_CONFIG}
$(KUBERNETES_FILES):
@./scripts/prep_local_devel_env.sh
prepare-local-env: $(KUBERNETES_FILES) ## Prepare the local environment for running the broker locally
@echo > /dev/null
build-image: ## Build a docker image with the broker binary
cp broker build/broker
docker build -f ${BUILD_DIR}/Dockerfile-src -t ${BROKER_IMAGE}:${TAG} ${BUILD_DIR}
@echo
@echo "Remember you need to push your image before calling make deploy"
@echo " docker push ${BROKER_IMAGE}:${TAG}"
release-image:
docker build -t ${BROKER_IMAGE}:${TAG} ${BUILD_DIR}
@echo
@echo "Remember you need to push your image before calling make deploy"
@echo " make push"
release: release-image
push:
docker push ${BROKER_IMAGE}:${TAG}
clean: ## Clean up your working environment
@rm -f broker
@rm -f build/broker
really-clean: clean ## Really clean up the working environment
@rm -f $(KUBERNETES_FILES)
cleanup-ci
deploy: ## Deploy a built broker docker image to a running cluster
@./scripts/deploy.sh ${BROKER_IMAGE}:${TAG} ${REGISTRY} ${ORG}
cleanup-ci: ## Cleanup after ci run
./scripts/broker-ci/cleanup-ci.sh
ci: ## Run CI (fmtcheck, vet, lint, build, test)
./scripts/broker-ci/local-ci.sh
help: ## Show this help screen
@echo 'Usage: make <OPTIONS> ... <TARGETS>'
@echo ''
@echo 'Available targets are:'
@echo ''
@grep -E '^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
.PHONY: run build-image release-image release push clean deploy ci cleanup-ci lint build vendor fmt fmtcheck test vet help