2017-05-08 19:33:37 +03:00
|
|
|
DOCKER_REGISTRY ?= docker.io
|
|
|
|
IMAGE_PREFIX ?= microsoft
|
2017-02-14 22:38:18 +03:00
|
|
|
IMAGE_TAG ?= canary
|
2017-05-09 02:12:05 +03:00
|
|
|
SHORT_NAME ?= draft
|
2017-06-02 04:32:49 +03:00
|
|
|
TARGETS = darwin/amd64 linux/amd64 linux/386 linux/arm windows/amd64
|
2017-01-18 11:10:11 +03:00
|
|
|
DIST_DIRS = find * -type d -exec
|
2017-04-21 18:19:58 +03:00
|
|
|
APP = draft
|
2017-01-18 11:10:11 +03:00
|
|
|
|
|
|
|
# go option
|
|
|
|
GO ?= go
|
|
|
|
PKG := $(shell glide novendor)
|
2017-03-13 22:18:29 +03:00
|
|
|
TAGS := kqueue
|
2017-01-18 11:10:11 +03:00
|
|
|
TESTS := .
|
|
|
|
TESTFLAGS :=
|
|
|
|
LDFLAGS :=
|
|
|
|
GOFLAGS :=
|
|
|
|
BINDIR := $(CURDIR)/bin
|
2017-04-21 18:19:58 +03:00
|
|
|
BINARIES := draft
|
2017-01-18 11:10:11 +03:00
|
|
|
|
|
|
|
# Required for globs to work correctly
|
|
|
|
SHELL=/bin/bash
|
|
|
|
|
|
|
|
.PHONY: all
|
|
|
|
all: build
|
|
|
|
|
|
|
|
.PHONY: build
|
|
|
|
build:
|
2017-05-08 19:33:37 +03:00
|
|
|
GOBIN=$(BINDIR) $(GO) install $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/Azure/draft/cmd/...
|
2017-01-18 11:10:11 +03:00
|
|
|
|
2017-04-21 18:19:58 +03:00
|
|
|
# usage: make clean build-cross dist APP=draft|draftd VERSION=v2.0.0-alpha.3
|
2017-01-18 11:10:11 +03:00
|
|
|
.PHONY: build-cross
|
|
|
|
build-cross: LDFLAGS += -extldflags "-static"
|
|
|
|
build-cross:
|
2017-05-08 19:33:37 +03:00
|
|
|
CGO_ENABLED=0 gox -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/Azure/draft/cmd/$(APP)
|
2017-01-18 11:10:11 +03:00
|
|
|
|
|
|
|
.PHONY: dist
|
|
|
|
dist:
|
|
|
|
( \
|
|
|
|
cd _dist && \
|
|
|
|
$(DIST_DIRS) cp ../LICENSE {} \; && \
|
|
|
|
$(DIST_DIRS) cp ../README.md {} \; && \
|
2017-04-21 18:19:58 +03:00
|
|
|
$(DIST_DIRS) tar -zcf draft-${VERSION}-{}.tar.gz {} \; \
|
2017-01-18 11:10:11 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
.PHONY: checksum
|
|
|
|
checksum:
|
2017-04-11 22:00:18 +03:00
|
|
|
for f in _dist/*.gz ; do \
|
2017-01-18 11:10:11 +03:00
|
|
|
shasum -a 256 "$${f}" | awk '{print $$1}' > "$${f}.sha256" ; \
|
|
|
|
done
|
|
|
|
|
2017-01-20 22:06:37 +03:00
|
|
|
.PHONY: check-docker
|
|
|
|
check-docker:
|
|
|
|
@if [ -z $$(which docker) ]; then \
|
|
|
|
echo "Missing \`docker\` client which is required for development"; \
|
|
|
|
exit 2; \
|
|
|
|
fi
|
|
|
|
|
2017-02-14 22:38:18 +03:00
|
|
|
.PHONY: check-helm
|
|
|
|
check-helm:
|
|
|
|
@if [ -z $$(which helm) ]; then \
|
|
|
|
echo "Missing \`helm\` client which is required for development"; \
|
|
|
|
exit 2; \
|
|
|
|
fi
|
|
|
|
|
2017-01-20 22:06:37 +03:00
|
|
|
.PHONY: docker-binary
|
|
|
|
docker-binary: BINDIR = ./rootfs/bin
|
|
|
|
docker-binary: GOFLAGS += -a -installsuffix cgo
|
|
|
|
docker-binary:
|
2017-05-08 19:33:37 +03:00
|
|
|
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 $(GO) build -o $(BINDIR)/draftd $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/Azure/draft/cmd/draftd
|
2017-01-20 22:06:37 +03:00
|
|
|
|
|
|
|
.PHONY: docker-build
|
2017-02-09 22:21:27 +03:00
|
|
|
docker-build: check-docker docker-binary compress-binary
|
2017-01-20 23:19:13 +03:00
|
|
|
docker build --rm -t ${IMAGE} .
|
2017-01-20 22:06:37 +03:00
|
|
|
docker tag ${IMAGE} ${MUTABLE_IMAGE}
|
|
|
|
|
2017-02-09 22:21:27 +03:00
|
|
|
.PHONY: compress-binary
|
|
|
|
compress-binary: BINDIR = ./rootfs/bin
|
|
|
|
compress-binary:
|
|
|
|
@if [ -z $$(which upx) ]; then \
|
|
|
|
echo "Missing \`upx\` tool to compress binaries"; \
|
|
|
|
else \
|
2017-04-21 18:19:58 +03:00
|
|
|
upx --quiet ${BINDIR}/draftd; \
|
2017-02-09 22:21:27 +03:00
|
|
|
fi
|
|
|
|
|
2017-02-14 22:38:18 +03:00
|
|
|
.PHONY: serve
|
|
|
|
serve: check-helm
|
2017-02-27 22:57:10 +03:00
|
|
|
helm install chart/ --name ${APP} --namespace kube-system \
|
2017-08-23 21:39:03 +03:00
|
|
|
--set image.repository=${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${SHORT_NAME},image.tag=${IMAGE_TAG}
|
2017-02-14 22:38:18 +03:00
|
|
|
|
2017-02-17 20:09:44 +03:00
|
|
|
.PHONY: unserve
|
|
|
|
unserve: check-helm
|
|
|
|
-helm delete --purge ${APP}
|
|
|
|
|
2017-02-14 22:38:18 +03:00
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
-rm bin/*
|
|
|
|
-rm rootfs/bin/*
|
2017-06-09 20:19:30 +03:00
|
|
|
-rm -rf _dist/
|
2017-02-14 22:38:18 +03:00
|
|
|
|
2017-01-18 11:10:11 +03:00
|
|
|
.PHONY: test
|
|
|
|
test: TESTFLAGS += -race -v
|
2017-09-13 00:48:29 +03:00
|
|
|
test: test-lint test-unit
|
2017-06-06 21:39:04 +03:00
|
|
|
|
|
|
|
test-cover:
|
|
|
|
scripts/cover.sh
|
2017-03-17 06:23:59 +03:00
|
|
|
|
|
|
|
.PHONY: test-lint
|
|
|
|
test-lint:
|
2017-05-17 02:10:50 +03:00
|
|
|
scripts/lint.sh
|
2017-01-18 11:10:11 +03:00
|
|
|
|
|
|
|
.PHONY: test-unit
|
|
|
|
test-unit:
|
2017-03-16 00:45:40 +03:00
|
|
|
$(GO) test $(GOFLAGS) -cover -run $(TESTS) $(PKG) $(TESTFLAGS)
|
2017-01-18 11:10:11 +03:00
|
|
|
|
2017-02-10 01:27:59 +03:00
|
|
|
.PHONY: test-e2e
|
|
|
|
test-e2e:
|
|
|
|
./tests/e2e.sh
|
|
|
|
|
2017-03-17 06:23:59 +03:00
|
|
|
HAS_GOMETALINTER := $(shell command -v gometalinter;)
|
2017-01-18 11:10:11 +03:00
|
|
|
HAS_GLIDE := $(shell command -v glide;)
|
|
|
|
HAS_GOX := $(shell command -v gox;)
|
|
|
|
HAS_GIT := $(shell command -v git;)
|
2017-06-03 18:31:59 +03:00
|
|
|
HAS_BINDATA := $(shell command -v go-bindata;)
|
2017-01-18 11:10:11 +03:00
|
|
|
|
|
|
|
.PHONY: bootstrap
|
|
|
|
bootstrap:
|
2017-03-17 06:23:59 +03:00
|
|
|
ifndef HAS_GOMETALINTER
|
|
|
|
go get -u github.com/alecthomas/gometalinter
|
|
|
|
gometalinter --install
|
|
|
|
endif
|
2017-01-18 11:10:11 +03:00
|
|
|
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)
|
2017-06-03 18:31:59 +03:00
|
|
|
endif
|
|
|
|
ifndef HAS_BINDATA
|
|
|
|
go get github.com/jteeuwen/go-bindata/...
|
2017-01-18 11:10:11 +03:00
|
|
|
endif
|
2017-05-09 22:28:28 +03:00
|
|
|
glide install --strip-vendor
|
2017-05-17 02:10:50 +03:00
|
|
|
scripts/setup-apimachinery.sh
|
2017-01-18 11:10:11 +03:00
|
|
|
|
|
|
|
include versioning.mk
|