-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (54 loc) · 2.19 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
ARTIFACT_OPERATOR=redis-operator
ARTIFACT_INITCONTAINER=init-container
# 0.0 shouldn't clobber any released builds
PREFIX=redisoperator/
#PREFIX = gcr.io/google_containers/
SOURCES := $(shell find $(SOURCEDIR) ! -name "*_test.go" -name '*.go')
CMDBINS := operator redisnode
TAG?=$(shell git tag|tail -1)
COMMIT=$(shell git rev-parse HEAD)
VERSION?=$(shell cat version.txt)
DATE=$(shell date +%Y-%m-%d/%H:%M:%S )
BUILDINFOPKG=github.com/amadeusitgroup/redis-operator/pkg/utils
LDFLAGS= -ldflags "-w -X ${BUILDINFOPKG}.TAG=${TAG} -X ${BUILDINFOPKG}.COMMIT=${COMMIT} -X ${BUILDINFOPKG}.VERSION=${VERSION} -X ${BUILDINFOPKG}.BUILDTIME=${DATE} -s"
all: build
plugin: build-kubectl-plugin install-plugin
install-plugin:
./tools/install-plugin.sh
build-%:
CGO_ENABLED=0 go build -i -installsuffix cgo ${LDFLAGS} -o bin/$* ./cmd/$*
buildlinux-%: ${SOURCES}
CGO_ENABLED=0 GOOS=linux go build -i -installsuffix cgo ${LDFLAGS} -o docker/$*/$* ./cmd/$*/main.go
container-%: buildlinux-%
@cd docker/$* && docker build -t $(PREFIX)$*:$(TAG) .
container-redisnode: buildlinux-redisnode
@cd docker/redisnode && docker build -t $(PREFIX)redisnode:$(TAG) .
build: $(addprefix build-,$(CMDBINS))
buildlinux: $(addprefix buildlinux-,$(CMDBINS))
container: $(addprefix container-,$(CMDBINS))
test:
./go.test.sh
push: container
@cd docker/${ARTIFACT_OPERATOR} && docker push $(PREFIX)$(ARTIFACT_OPERATOR):$(TAG)
clean:
rm -f ${ARTIFACT_OPERATOR}
# Install all the build and lint dependencies
setup:
go get -u github.com/alecthomas/gometalinter
gometalinter --install
echo "make check" > .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
.PHONY: setup
# gofmt and goimports all go files
fmt:
find . -name '*.go' -not -wholename './vendor/*' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done
.PHONY: fmt
# Run all the linters
lint:
gometalinter --vendor ./... -e pkg/client -e _generated -e test --deadline 15m -D gocyclo -D errcheck -D aligncheck -D maligned -D gas
.PHONY: lint
# Run only fast linters
lint-fast:
gometalinter --fast --vendor ./... -e pkg/client -e _generated -e test --deadline 9m -D gocyclo -D errcheck -D aligncheck -D maligned
.PHONY: lint-fast
.PHONY: build push clean test