-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
83 lines (62 loc) · 2.01 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
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
## Tool Binaries
GO ?= go
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
GORELEASER ?= $(LOCALBIN)/goreleaser
## Tool Versions
GOLANGCI_LINT_VERSION ?= v1.60.1
GORELEASER_VERSION ?= v2.2.0
.PHONY: all
all: help
##@ General
.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Test
.PHONY: test
test: ## Run unit tests.
$(GO) test ./pkg/...
##@ Lint
.PHONY: lint
lint: golangci-lint ## Lint.
$(GOLANGCI_LINT) run
##@ Release
.PHONY: release
release: goreleaser ## Test release locally.
$(GORELEASER) release --snapshot --clean
##@ Run
RUN_FLAGS ?= \
--config-path=config/kubeadm-join.storage.yaml \
--api-server-endoint=10.0.020:6443 \
--token=token \
--ca-cert-hash=sha356:hash \
--label-key=node.mmontes.io/type \
--label-value=compute \
--taint=node.mmontes.io/storage
.PHONY: run
run: lint ## Run a controller from your host.
$(GO) run cmd/kubeadm-join-config/*.go $(RUN_FLAGS)
##@ Build
.PHONY: build
build: ## Build binary.
$(GO) build -o bin/kubeadm-join-config cmd/kubeadm-join-config/*.go
##@ Dependencies
.PHONY: golangci-lint
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
GOBIN=$(LOCALBIN) $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
.PHONY: goreleaser
goreleaser: $(GORELEASER) ## Download goreleaser locally if necessary.
$(GORELEASER): $(LOCALBIN)
GOBIN=$(LOCALBIN) $(GO) install github.com/goreleaser/goreleaser/v2@$(GORELEASER_VERSION)