-
Notifications
You must be signed in to change notification settings - Fork 19
/
Makefile
63 lines (48 loc) · 1.37 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
IMAGE_REGISTRY?=ghcr.io/k8snetworkplumbingwg/
IMAGE_VERSION?=latest
IMAGE_NAME?=$(IMAGE_REGISTRY)sriov-network-metrics-exporter:$(IMAGE_VERSION)
IMAGE_BUILDER?=docker
# Package related
BINARY_NAME=sriov-exporter
BUILDDIR=$(CURDIR)/build
DOCKERARGS?=
ifdef HTTP_PROXY
DOCKERARGS += --build-arg http_proxy=$(HTTP_PROXY)
endif
ifdef HTTPS_PROXY
DOCKERARGS += --build-arg https_proxy=$(HTTPS_PROXY)
endif
# Go settings
GO = go
GO_BUILD_OPTS ?=CGO_ENABLED=0
GO_LDFLAGS ?= -s -w
GO_FLAGS ?=
GO_TAGS ?=-tags no_openssl
export GOPATH?=$(shell go env GOPATH)
# debug
V ?= 0
Q = $(if $(filter 1,$V),,@)
all: build image-build test
clean:
rm -rf bin
go clean -modcache -testcache
build:
$Q cd $(CURDIR)/cmd && $(GO_BUILD_OPTS) go build -ldflags '$(GO_LDFLAGS)' $(GO_FLAGS) -o $(BUILDDIR)/$(BINARY_NAME) $(GO_TAGS) -v
image-build:
@echo "Bulding container image $(IMAGE_NAME)"
$(IMAGE_BUILDER) build -f Dockerfile -t $(IMAGE_NAME) $(DOCKERARGS) .
image-push:
$(IMAGE_BUILDER) push $(IMAGE_NAME)
test:
go test ./... -count=1
test-coverage:
go test ./... -coverprofile cover.out
go tool cover -func cover.out
go-lint-install:
go install github.com/golangci/golangci-lint/cmd/[email protected]
go-lint: go-lint-install
go mod tidy
go fmt ./...
golangci-lint run --color always -v ./...
go-lint-report: go-lint-install
golangci-lint run --color always -v ./... &> golangci-lint.txt