-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
77 lines (62 loc) · 2.03 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
# SPDX-FileCopyrightText: 2021 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0
REGISTRY := europe-docker.pkg.dev/gardener-project/public
EXECUTABLE := aws-custom-route-controller
PROJECT := github.com/gardener/aws-custom-route-controller
IMAGE_REPOSITORY := $(REGISTRY)/gardener/aws-custom-route-controller
REPO_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
VERSION := $(shell cat VERSION)
IMAGE_TAG := $(VERSION)
EFFECTIVE_VERSION := $(VERSION)-$(shell git rev-parse HEAD)
GOARCH := amd64
TOOLS_DIR := hack/tools
include $(TOOLS_DIR)/tools.mk
.PHONY: tidy
tidy:
go mod tidy
# build local executable
.PHONY: build-local
build-local:
@CGO_ENABLED=1 go build -o $(EXECUTABLE) \
-race \
-ldflags "-X 'main.Version=$(EFFECTIVE_VERSION)' -X 'main.ImageTag=$(IMAGE_TAG)'"\
main.go
.PHONY: release
release:
@CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) go build -o $(EXECUTABLE) \
-ldflags "-w -X 'main.Version=$(EFFECTIVE_VERSION)' -X 'main.ImageTag=$(IMAGE_TAG)'"\
main.go
.PHONY: check
check: $(GOIMPORTS) $(GOLANGCI_LINT)
go vet ./...
GOIMPORTS=$(GOIMPORTS) GOLANGCI_LINT=$(GOLANGCI_LINT) hack/check.sh ./...
# Run go fmt against code
.PHONY: format
format: $(GOIMPORTS)
$(GOIMPORTS) -l -w main.go ./pkg
.PHONY: docker-images
docker-images:
@docker build -t $(IMAGE_REPOSITORY):$(IMAGE_TAG) -f Dockerfile .
.PHONY: docker-images-linux-amd64
docker-images-linux-amd64:
@docker buildx build --platform linux/amd64 -t $(IMAGE_REPOSITORY):$(IMAGE_TAG) -f Dockerfile .
.PHONY: generate
generate: $(MOCKGEN)
@MOCKGEN=$(shell realpath $(MOCKGEN)) go generate ./pkg/...
.PHONY: sast
sast: $(GOSEC)
@./hack/sast.sh
.PHONY: sast-report
sast-report: $(GOSEC)
@./hack/sast.sh --gosec-report true
# Run tests
.PHONY: test
test:
@env go test ./pkg/...
.PHONY: update-dependencies
update-dependencies:
@env go get -u
@make tidy
.PHONY: verify
verify: check format test sast-report