-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
106 lines (90 loc) · 2.25 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
SHELL := /bin/bash -o pipefail
export GO111MODULE=on
VERSION_PACKAGE = github.com/replicatedhq/ekco/pkg/version
VERSION ?= `git describe --tags --dirty`
DATE = `date -u +"%Y-%m-%dT%H:%M:%SZ"`
CURRENT_USER=$(shell id -u -n)
ROOK_VERSION=1.11.8
ifndef GIT_SHA
GIT_TREE = $(shell git rev-parse --is-inside-work-tree 2>/dev/null)
ifneq "$(GIT_TREE)" ""
define GIT_UPDATE_INDEX_CMD
git update-index --assume-unchanged
endef
define GIT_SHA
`git rev-parse HEAD`
endef
else
define GIT_UPDATE_INDEX_CMD
echo "Not a git repo, skipping git update-index"
endef
define GIT_SHA
""
endef
endif
endif
define LDFLAGS
-ldflags "\
-X $(VERSION_PACKAGE).version=$(VERSION) \
-X $(VERSION_PACKAGE).gitSHA=$(GIT_SHA) \
-X $(VERSION_PACKAGE).buildTime=$(DATE) \
"
endef
.PHONY: clean
clean:
rm -rf ./bin
.PHONY: deps
deps:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin
.PHONY: lint
lint:
golangci-lint run ./...
.PHONY: vet
vet:
go vet ./...
.PHONY: test
test: lint vet
go test ./pkg/... ./cmd/...
.PHONY: build
build:
go build $(LDFLAGS) -o bin/ekco cmd/ekco/main.go
DOCKER_IMAGE ?= replicated/ekco:latest
.PHONY: docker-image
docker-image:
docker build \
-t $(DOCKER_IMAGE) \
-f deploy/Dockerfile \
--build-arg git_sha="$(GIT_SHA)" \
--build-arg version="$(VERSION)" \
--build-arg rook_version="$(ROOK_VERSION)" \
.
.PHONY: build-ttl.sh
build-ttl.sh: ## Build the EKCO Docker container and deploy it to ttl.sh for use in the development environment
docker build \
-t ttl.sh/${CURRENT_USER}/ekco:12h \
-f deploy/Dockerfile \
--build-arg git_sha=dev \
--build-arg version=dev \
--build-arg rook_version="$(ROOK_VERSION)" \
.
docker push ttl.sh/${CURRENT_USER}/ekco:12h
.PHONY: generate-mocks
generate-mocks: ## Generate mocks tests for CLI and preflight. More info: https://github.com/golang/mock
go install github.com/golang/mock/[email protected]
mockgen -source=pkg/k8s/exec.go -destination=pkg/k8s/mock/mock_exec.go
.PHONY: scan
scan:
trivy fs \
--scanners vuln \
--exit-code=1 \
--severity="HIGH,CRITICAL" \
--ignore-unfixed \
./
.PHONY: scan-image
scan-image:
trivy image \
--scanners vuln \
--exit-code=1 \
--severity="HIGH,CRITICAL" \
--ignore-unfixed \
$(DOCKER_IMAGE)