forked from gardener/network-problem-detector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (63 loc) · 2.43 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
# 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 := nwpdcli
PROJECT := github.com/gardener/network-problem-detector
IMAGE_REPOSITORY := $(REGISTRY)/gardener/network-problem-detector
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 #
#########################################
TOOLS_DIR := hack/tools
include $(TOOLS_DIR)/tools.mk
.PHONY: tidy
tidy:
go mod tidy
.PHONY: check
check: $(GOIMPORTS) $(GOLANGCI_LINT)
go vet ./...
GOIMPORTS=$(GOIMPORTS) GOLANGCI_LINT=$(GOLANGCI_LINT) hack/check.sh ./cmd/... ./pkg/...
.PHONY: format
format: $(GOIMPORTS)
@GOIMPORTS=$(GOIMPORTS) $(REPO_ROOT)/hack/format.sh ./cmd ./pkg
.PHONY: build
build:
@CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) GO111MODULE=on go build -o $(EXECUTABLE) \
-ldflags "-X 'main.Version=$(EFFECTIVE_VERSION)' -X 'main.ImageTag=$(IMAGE_TAG)'"\
./cmd/nwpd
.PHONY: build-local
build-local:
@CGO_ENABLED=1 GO111MODULE=on go build -o $(EXECUTABLE) \
-race \
-ldflags "-X 'main.Version=$(EFFECTIVE_VERSION)' -X 'main.ImageTag=$(IMAGE_TAG)'"\
./cmd/nwpd
.PHONY: release
release:
@CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) GO111MODULE=on go build -o $(EXECUTABLE) \
-ldflags "-w -X 'main.Version=$(EFFECTIVE_VERSION)' -X 'main.ImageTag=$(IMAGE_TAG)'"\
./cmd/nwpd
.PHONY: test
test:
go test ./pkg/...
.PHONY: verify
verify: check format test
.PHONY: generate-proto
generate-proto:
@go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
@go install github.com/twitchtv/twirp/protoc-gen-twirp@v8.1.3
@protoc --go_out=. --go_opt=paths=source_relative \
--experimental_allow_proto3_optional \
--twirp_out=. --twirp_opt=paths=source_relative \
pkg/common/nwpd/nwpd.proto
@GOIMPORTS=$(GOIMPORTS) $(REPO_ROOT)/hack/format.sh ./pkg
.PHONY: prepare-default-image
prepare-default-image:
@echo "$(IMAGE_REPOSITORY):$(EFFECTIVE_VERSION)" >$(REPO_ROOT)/pkg/deploy/DEFAULT_IMAGE
.PHONY: docker-images
docker-images:
@docker build -t $(IMAGE_REPOSITORY):$(IMAGE_TAG) -f Dockerfile .