forked from pusher/k8s-spot-rescheduler
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
91 lines (72 loc) · 1.95 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
include .env
BINARY := k8s-spot-rescheduler
VERSION := $(shell git describe --always --dirty --tags 2>/dev/null || echo "undefined")
RED := \033[31m
GREEN := \033[32m
NC := \033[0m
IMG ?= quay.io/pusher/k8s-spot-rescheduler
.NOTPARALLEL:
.PHONY: all
all: distclean test build
.PHONY: build
build: clean $(BINARY)
.PHONY: clean
clean:
rm -f $(BINARY)
.PHONY: distclean
distclean: clean
rm -rf vendor
rm -rf release
.PHONY: fmt
fmt:
$(GO) fmt ./...
.PHONY: vet
vet: vendor
$(GO) vet ./...
.PHONY: lint
lint: vendor
@ echo "$(GREEN)Linting code$(NC)"
$(LINTER) run --disable-all \
--exclude-use-default=false \
--enable=govet \
--enable=ineffassign \
--enable=deadcode \
--enable=golint \
--enable=goconst \
--enable=gofmt \
--enable=goimports \
--skip-dirs=pkg/client/ \
--deadline=120s \
--tests ./...
@ echo
vendor:
@ echo "$(GREEN)Pulling dependencies$(NC)"
$(DEP) ensure --vendor-only
@ echo
.PHONY: test
test: vendor
@ echo "$(GREEN)Running test suite$(NC)"
$(GO) test ./...
@ echo
.PHONY: check
check: fmt lint vet test
.PHONY: build
build: clean $(BINARY)
$(BINARY): fmt vet
CGO_ENABLED=0 $(GO) build -o $(BINARY) -ldflags="-X main.VERSION=${VERSION}" github.com/pusher/k8s-spot-rescheduler
.PHONY: docker-build
docker-build: check
docker build --build-arg VERSION=${VERSION} . -t ${IMG}:${VERSION}
@echo "$(GREEN)Built $(IMG):$(VERSION)$(NC)"
TAGS ?= latest
.PHONY: docker-tag
docker-tag: docker-build
@IFS=","; tags=${TAGS}; for tag in $${tags}; do docker tag ${IMG}:${VERSION} ${IMG}:$${tag}; echo "$(GREEN)Tagged $(IMG):$(VERSION) as $${tag}$(NC)"; done
PUSH_TAGS ?= ${VERSION}, latest
.PHONY: docker-push
docker-push: docker-build docker-tag
@IFS=","; tags=${PUSH_TAGS}; for tag in $${tags}; do docker push ${IMG}:$${tag}; echo "$(GREEN)Pushed $(IMG):$${tag}$(NC)"; done
TAGS ?= latest
.PHONY: docker-clean
docker-clean:
@IFS=","; tags=${TAGS}; for tag in $${tags}; do docker rmi -f ${IMG}:${VERSION} ${IMG}:$${tag}; done