This repository has been archived by the owner on Nov 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
100 lines (80 loc) · 2.51 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
93
94
95
96
97
98
99
100
DOCKER_REGISTRY ?= gcr.io
IMAGE_PREFIX ?= kubernetes-helm-rudder-appcontroller
SHORT_NAME ?= rudder
DIST_DIRS = find * -type d -exec
APP = rudder
PACKAGE = github.com/helm/rudder-appcontroller
IMAGE_REPO = helm/rudder-appcontroller
# go option
GO ?= go
PKG := $(shell glide novendor)
TAGS :=
TESTS := .
TESTFLAGS :=
LDFLAGS :=
GOFLAGS :=
BINDIR := $(CURDIR)/bin
BINARIES := rudder
# dind options
K8S_CLUSTER_MARKER = .k8s-cluster
K8S_VERSION ?= v1.5
HELM_BINARY_PATH ?= /tmp/
APISERVER_PORT ?= 8080
# Required for globs to work correctly
SHELL=/bin/bash
.PHONY: all
all: build
.PHONY: build
build:
GOBIN=$(BINDIR) $(GO) install $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ${PACKAGE}/cmd/...
.PHONY: docker-binary
docker-binary: BINDIR = ./rootfs
docker-binary: GOFLAGS += -a -installsuffix cgo
docker-binary:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 $(GO) build -o $(BINDIR)/rudder $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ${PACKAGE}/cmd/rudder
.PHONY: docker-build
docker-build: docker-binary
docker build --rm -t $(IMAGE_REPO) rootfs
.PHONY: clean
clean:
@rm -rf $(BINDIR) ./rootfs/rudder
-rm e2e.test
HAS_GLIDE := $(shell command -v glide;)
HAS_GOX := $(shell command -v gox;)
HAS_GIT := $(shell command -v git;)
.PHONY: bootstrap
bootstrap:
ifndef HAS_GLIDE
go get -u github.com/Masterminds/glide
endif
ifndef HAS_GOX
go get -u github.com/mitchellh/gox
endif
ifndef HAS_GIT
$(error You must install Git)
endif
glide install --strip-vendor
go build -o bin/protoc-gen-go ./vendor/github.com/golang/protobuf/protoc-gen-go
include versioning.mk
.PHONY: img-in-dind
img-in-dind: docker-build $(K8S_CLUSTER_MARKER)
IMAGE_REPO=$(IMAGE_REPO) ./scripts/import.sh
.PHONY: e2e
e2e: $(K8S_CLUSTER_MARKER) img-in-dind prepare-helm
go test -c -o e2e.test ./e2e/
PATH=$(PATH):$(HELM_BINARY_PATH)/linux-amd64 ./e2e.test --cluster-url=http://0.0.0.0:$(APISERVER_PORT)
.PHONY: clean-all
clean-all: clean clean-k8s
.PHONY: clean-k8s
clean-k8s:
./kubeadm-dind-cluster/fixed/dind-cluster-$(K8S_VERSION).sh clean
-rm $(K8S_CLUSTER_MARKER)
$(K8S_CLUSTER_MARKER):
if [ ! -d "kubeadm-dind-cluster" ]; then git clone https://github.com/Mirantis/kubeadm-dind-cluster.git; fi
./kubeadm-dind-cluster/fixed/dind-cluster-$(K8S_VERSION).sh up
touch $(K8S_CLUSTER_MARKER)
.PHONE: prepare-helm
prepare-helm:
pushd $(HELM_BINARY_PATH) \
&& curl https://kubernetes-helm.storage.googleapis.com/helm-v2.3.0-linux-amd64.tar.gz > helm.tar.gz \
&& tar xf helm.tar.gz && popd