-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
96 lines (80 loc) · 2.64 KB
/
Makefile
File metadata and controls
96 lines (80 loc) · 2.64 KB
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
# Setting SHELL to bash allows bash commands to be executed by recipes.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
SHELL = /usr/bin/env bash -o pipefail
.SHELLFLAGS = -ec
SOURCES := Makefile go.mod go.sum $(shell find $(DEST) -name '*.go' 2>/dev/null)
VERSION ?= $(shell git describe --dirty --tags --match='v*' 2>/dev/null || git rev-parse --short HEAD)
REGISTRY ?= ghcr.io
REPO ?= stackitcloud/machine-controller-manager-provider-stackit
PUSH ?= true
PLATFORMS ?= amd64 arm64
IS_DEV ?= true
ifeq ($(IS_DEV), true)
REPO := $(REPO)-dev
endif
include ./hack/tools.mk
.PHONY: all
all: verify
.PHONY: image
image: $(KO) ## Builds a single binary specified by TARGET
KO_DOCKER_REPO=$(REGISTRY)/$(REPO) \
$(KO) build --push=$(PUSH) \
--image-label org.opencontainers.image.source="https://github.com/stackitcloud/machine-controller-manager-provider-stackit" \
--sbom none -t $(VERSION) \
--bare \
--platform linux/amd64,linux/arm64 \
./cmd/machine-controller
.PHONY: clean-tools-bin
clean-tools-bin: ## Empty the tools binary directory.
rm -rf $(TOOLS_BIN_DIR)/* $(TOOLS_BIN_DIR)/.version_*
.PHONY: fmt
fmt: $(GOIMPORTS_REVISER) ## Run go fmt against code.
go fmt ./...
$(GOIMPORTS_REVISER) .
.PHONY: modules
modules: ## Runs go mod to ensure modules are up to date.
go mod tidy
.PHONY: lint
lint: $(GOLANGCI_LINT) ## Run golangci-lint against code.
$(GOLANGCI_LINT) run ./...
.PHONY: check
check: lint test ## Check everything (lint + test).
.PHONY: test
test: ## Run tests.
./hack/test.sh ./cmd/... ./pkg/...
.PHONY: verify-fmt
verify-fmt: fmt ## Verify go code is formatted.
@if !(git diff --quiet HEAD); then \
echo "unformatted files detected, please run 'make fmt'"; exit 1; \
fi
.PHONY: verify-modules
verify-modules: modules ## Verify go module files are up to date.
@if !(git diff --quiet HEAD -- go.sum go.mod); then \
echo "go module files are out of date, please run 'make modules'"; exit 1; \
fi
.PHONY: verify
verify: verify-fmt verify-modules check
.PHONY: mocks
mocks: $(MOCKGEN)
# clean mocks
@find . -name '*_mock.go' -delete || true
# generate mocks
@go mod download
.PHONY: generate
generate: mocks
go generate ./...
.PHONY: start
start:
go run \
cmd/machine-controller/main.go \
--control-kubeconfig=$(CONTROL_KUBECONFIG) \
--target-kubeconfig=$(TARGET_KUBECONFIG) \
--namespace=$(CONTROL_NAMESPACE) \
--machine-creation-timeout=20m \
--machine-drain-timeout=5m \
--machine-health-timeout=10m \
--machine-pv-detach-timeout=2m \
--machine-safety-apiserver-statuscheck-timeout=30s \
--machine-safety-apiserver-statuscheck-period=1m \
--machine-safety-orphan-vms-period=30m \
--v=3