forked from dibi-codes/kube-resource-explorer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
80 lines (65 loc) · 1.93 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
GIT_COMMIT=$(shell git rev-parse --short HEAD)
GOTEST=go test
GOCOVER=go tool cover
ARCHES=amd64 arm64
PLATFORMS=darwin linux windows
BUILDARCH?=$(shell uname -m)
BUILDPLATFORM?=$(shell uname -s)
ifeq ($(BUILDARCH),aarch64)
BUILDARCH=arm64
endif
ifeq ($(BUILDARCH),x86_64)
BUILDARCH=amd64
endif
ifeq ($(BUILDPLATFORM),Darwin)
BUILDPLATFORM=darwin
endif
ifeq ($(BUILDPLATFORM),Linux)
BUILDPLATFORM=linux
endif
ifeq ($(BUILDPLATFORM),Win)
BUILDPLATFORM=windows
endif
# unless otherwise set, I am building for my own architecture, i.e. not cross-compiling
ARCH ?= $(BUILDARCH)
PLATFORM ?= $(BUILDPLATFORM)
# canonicalized names for target architecture
ifeq ($(ARCH),aarch64)
override ARCH=arm64
endif
ifeq ($(ARCH),x86_64)
override ARCH=amd64
endif
ifeq ($(PLATFORM),Darwin)
override PLATFORM=darwin
endif
ifeq ($(PLATFORM),Linux)
override PLATFORM=linux
endif
ifeq ($(PLATFORM),Win)
override PLATFORM=windows
endif
VERSION ?= $(GIT_COMMIT)
DEFAULTIMAGE ?= dibi/kube-resource-explorer:$(VERSION)
.PHONY: all
all: clean test cover build install
test:
$(shell mkdir TestResults)
$(GOTEST) -v -coverprofile=TestResults/coverage.out ./...
cover: test
$(GOCOVER) -func=TestResults/coverage.out
$(GOCOVER) -html=TestResults/coverage.out
build:
CGO_ENABLED=0 GOOS=$(PLATFORM) GOARCH=$(ARCH) GO111MODULE=on\
go build -ldflags "-X main.GitCommit=${GIT_COMMIT}" -a -installsuffix cgo -o ./out/kube-resource-explorer-$(PLATFORM)-$(ARCH) ./cmd/kube-resource-explorer
install:
CGO_ENABLED=0 GOOS=$(PLATFORM) GOARCH=$(ARCH) GO111MODULE=on\
go install -ldflags "-X main.GitCommit=${GIT_COMMIT}" -a -installsuffix cgo ./cmd/kube-resource-explorer
run:
CGO_ENABLED=0 GOOS=$(PLATFORM) GOARCH=$(ARCH) GO111MODULE=on\
go run -ldflags "-X main.GitCommit=${GIT_COMMIT}" -a -installsuffix cgo ./cmd/kube-resource-explorer
package:
DOCKER_BUILDKIT=1 docker build -t $(DEFAULTIMAGE) .
clean:
rm -rf ./TestResults/* ./out/*
docker rmi $(DEFAULTIMAGE) || true