forked from Shopify/kubeaudit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
57 lines (43 loc) · 1.31 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
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
BINARY_NAME=kubeaudit
BINARY_UNIX=$(BINARY_NAME)_unix
LDFLAGS=$(shell build/ldflags.sh)
# kubernetes client won't build with go<1.10
GOVERSION:=$(shell go version | awk '{print $$3}')
GOVERSION_MIN:=go1.11
GOVERSION_CHECK=$(shell printf "%s\n%s\n" "$(GOVERSION)" "$(GOVERSION_MIN)" | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | head -n 1)
export GO111MODULE=on
ifneq ($(GOVERSION_MIN), $(GOVERSION_CHECK))
$(error Detected Go version $(GOVERSION) < required version $(GOVERSION_MIN))
endif
all: setup test build
build:
$(GOBUILD) -o $(BINARY_NAME) -v -ldflags=all="$(LDFLAGS)"
install:
cp $(BINARY_NAME) $(GOPATH)/bin/kubeaudit
plugin:
cp $(BINARY_NAME) $(GOPATH)/bin/kubectl-audit
test:
./test.sh
show-coverage: test
go tool cover -html=coverage.txt
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
rm -f $(BINARY_UNIX)
check_version:
$(GOBUILD) -o $(BINARY_NAME)
./$(BINARY_NAME) version
setup:
go mod download
go mod tidy
# Cross Compilation
build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_UNIX) -v
docker-build:
docker run --rm -it -v "$(GOPATH)":/go -w /go/src/github.com/Shopify/kubeaudit golang:1.12 go build -o "$(BINARY_UNIX)" -v
.PHONY: build clean test check_version build-linux docker-build