-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
401 lines (327 loc) · 23 KB
/
Makefile
File metadata and controls
401 lines (327 loc) · 23 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
################################################################################
# This file is AUTOGENERATED with <https://github.com/sapcc/go-makefile-maker> #
# Edit Makefile.maker.yaml instead. #
################################################################################
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company
# SPDX-License-Identifier: Apache-2.0
# macOS ships with make 3.81 from 2006, which does not support all the features that we want (e.g. --warn-undefined-variables)
ifeq ($(MAKE_VERSION),3.81)
ifeq (,$(shell which gmake 2>/dev/null))
$(error We do not support this "make" version ($(MAKE_VERSION)) which is two decades old. Please install a newer version, e.g. using "brew install make")
else
$(error We do not support this "make" version ($(MAKE_VERSION)) which is two decades old. You have a newer GNU make installed, so please run "gmake" instead)
endif
endif
MAKEFLAGS=--warn-undefined-variables
# /bin/sh is dash on Debian which does not support all features of ash/bash
# to fix that we use /bin/bash only on Debian to not break Alpine
ifneq (,$(wildcard /etc/os-release)) # check file existence
ifneq ($(shell grep -c debian /etc/os-release),0)
SHELL := /bin/bash
endif
endif
UNAME_S := $(shell uname -s)
SED = sed
XARGS = xargs
ifeq ($(UNAME_S),Darwin)
SED = gsed
XARGS = gxargs
endif
default: build-all
# Image to use all building/pushing image targets
IMG ?= controller:latest
# CONTAINER_TOOL defines the container tool to be used for building images.
# The default is docker, but it can be overridden to use other tools (i.e. podman or nerdctl).
CONTAINER_TOOL ?= docker
# KIND_CLUSTER defines the name of the Kind cluster to be used for the tilt setup.
KIND_CLUSTER ?= network
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)
install-gofumpt: FORCE
@if ! hash gofumpt 2>/dev/null; then printf "\e[1;36m>> Installing gofumpt...\e[0m\n"; go install mvdan.cc/gofumpt@latest; fi
install-kubebuilder: FORCE
@set -eou pipefail; if ! hash kubebuilder 2>/dev/null; then printf "\e[1;36m>> Installing kubebuilder...\e[0m\n"; if command -v curl >/dev/null 2>&1; then GET="curl -sLo"; elif command -v wget >/dev/null 2>&1; then GET="wget -O"; else echo "Didn't find curl or wget to download kubebuilder"; exit 2; fi; BIN=$$(go env GOBIN); if [[ -z $$BIN ]]; then BIN=$$(go env GOPATH)/bin; fi; $$GET "$$BIN/kubebuilder" "https://go.kubebuilder.io/dl/latest/$$(go env GOOS)/$$(go env GOARCH)"; chmod +x "$$BIN/kubebuilder"; fi
install-kustomize: FORCE
@if ! hash kustomize 2>/dev/null; then printf "\e[1;36m>> Installing kustomize...\e[0m\n"; go install sigs.k8s.io/kustomize/kustomize/v5@latest; fi
install-crd-ref-docs: FORCE
@if ! hash crd-ref-docs 2>/dev/null; then printf "\e[1;36m>> Installing crd-ref-docs...\e[0m\n"; go install github.com/elastic/crd-ref-docs@latest; fi
bin/golangci-lint-custom: .custom-gcl.yaml
@hash golangci-lint 2>/dev/null || (printf "\e[1;31m>> golangci-lint not found, please install it first\e[0m\n"; exit 1)
golangci-lint custom --destination $(LOCALBIN) --name golangci-lint-custom
lint: FORCE bin/golangci-lint-custom ## Run golangci-lint linter
@printf "\e[1;36m>> golangci-lint\e[0m\n"
@bin/golangci-lint-custom config verify
@bin/golangci-lint-custom run
fmt: FORCE install-gofumpt
@printf "\e[1;36m>> gofumpt -l -w .\e[0m\n"
@gofumpt -l -w $(shell git ls-files '*.go' | grep -v '^internal/provider/openconfig')
# Run the e2e tests against a k8s cluster.
test-e2e: FORCE
@command -v kind >/dev/null 2>&1 || { \
echo "Kind is not installed. Please install Kind manually."; \
exit 1; \
}
@kind get clusters | grep -q $(KIND_CLUSTER) || { \
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
exit 1; \
}
@printf "\e[1;36m>> go test ./test/e2e/ -v -ginkgo.v\e[0m\n"
@KIND_CLUSTER=$(KIND_CLUSTER) go test ./test/e2e/ -v -ginkgo.v
docker-build: FORCE
@printf "\e[1;36m>> $(CONTAINER_TOOL) build --tag=$(IMG) .\e[0m\n"
@$(CONTAINER_TOOL) build --build-arg=BININFO_BUILD_DATE=$(BININFO_BUILD_DATE) --build-arg=BININFO_COMMIT_HASH=$(BININFO_COMMIT_HASH) --build-arg=BININFO_VERSION=$(BININFO_VERSION) --tag=$(IMG) .
docker-push: FORCE
@printf "\e[1;36m>> $(CONTAINER_TOOL) push $(IMG)\e[0m\n"
@$(CONTAINER_TOOL) push $(IMG)
# Generate a consolidated YAML with CRDs and deployment.
build-installer: FORCE generate install-kustomize
@printf "\e[1;36m>> kustomize build config/default > dist/install.yaml\e[0m\n"
@mkdir -p dist; kustomize build config/default > dist/install.yaml
# Deploy controller to the k8s cluster
deploy: FORCE generate install-kustomize
@printf "\e[1;36m>> kustomize build config/default | kubectl apply -f -\e[0m\n"
@kustomize build config/default | kubectl apply -f -
# Undeploy controller from the k8s cluster
undeploy: FORCE install-kustomize
@printf "\e[1;36m>> kustomize build config/default | kubectl delete -f -\e[0m\n"
@kustomize build config/default | kubectl delete --ignore-not-found=true -f -
# Install CRDs into the k8s cluster
deploy-crds: FORCE generate install-kustomize
@printf "\e[1;36m>> kustomize build config/crd | kubectl apply -f -\e[0m\n"
@kustomize build config/crd | kubectl apply -f -
# Uninstall CRDs from the k8s cluster
undeploy-crds: FORCE install-kustomize
@printf "\e[1;36m>> kustomize build config/crd | kubectl delete -f -\e[0m\n"
@kustomize build config/crd | kubectl delete --ignore-not-found=true -f -
# Create a Kind cluster for local development and testing.
kind-create: FORCE
@command -v kind >/dev/null 2>&1 || { \
echo "Kind is not installed. Please install Kind manually."; \
exit 1; \
}
KIND_CLUSTER_NAME=$(KIND_CLUSTER) CONTAINER_TOOL=$(CONTAINER_TOOL) ./hack/kind-with-registry.sh
# Delete the Kind cluster created for local development and testing.
kind-delete: FORCE
@command -v kind >/dev/null 2>&1 || { \
echo "Kind is not installed. Please install Kind manually."; \
exit 1; \
}
@printf "\e[1;36m>> kind delete cluster --name=$(KIND_CLUSTER)\e[0m\n"
KIND_EXPERIMENTAL_PROVIDER=$(CONTAINER_TOOL) kind delete cluster --name=$(KIND_CLUSTER)
$(CONTAINER_TOOL) stop kind-registry && $(CONTAINER_TOOL) rm kind-registry
tilt-up: FORCE kind-create
@command -v tilt >/dev/null 2>&1 || { \
echo "Tilt is not installed. Please install Tilt manually."; \
exit 1; \
}
@printf "\e[1;36m>> tilt up --context kind-$(KIND_CLUSTER)\e[0m\n"
@tilt up --context kind-$(KIND_CLUSTER)
manifests: generate
# Generate manifests e.g. CRD, RBAC etc.
charts: FORCE install-kubebuilder generate
@printf "\e[1;36m>> kubebuilder edit --plugins=helm/v2-alpha\e[0m\n"
@mv charts/network-operator charts/chart
@kubebuilder edit --plugins=helm/v2-alpha --output-dir=charts
@mv charts/chart charts/network-operator && rm -rf dist
netop-provider:
@printf "\e[1;36m>> go build -o build/netop-provider ./hack/provider\e[0m\n"
@go build -o build/netop-provider ./hack/provider
@printf "\e[1;36m>> ./build/netop-provider --help\e[0m\n"
@./build/netop-provider --help
TEST_SERVER_IMG ?= ghcr.io/ironcore-dev/gnmi-test-server:latest
docker-build-test-gnmi-server: FORCE
@printf "\e[1;36m>> $(CONTAINER_TOOL) build --tag=$(TEST_SERVER_IMG) ./test/gnmi\e[0m\n"
@$(CONTAINER_TOOL) build --tag=$(TEST_SERVER_IMG) ./test/gnmi
docker-run-test-gnmi-server: FORCE docker-build-test-gnmi-server
@printf "\e[1;36m>> $(CONTAINER_TOOL) run -p 8000:8000 -p 9339:9339 $(TEST_SERVER_IMG)\e[0m\n"
@$(CONTAINER_TOOL) run --rm -p 8000:8000 -p 9339:9339 $(TEST_SERVER_IMG)
# TEST_LAB_IMG defines the image to used for packaging the lab tests.
TEST_LAB_IMG ?= ghcr.io/ironcore-dev/network-operator-lab-test:latest
test-lab: FORCE
@printf "\e[1;36m>> go test ./test/lab/ -v\e[0m\n"
@go test ./test/lab/ -v
docker-build-test-lab: FORCE
@printf "\e[1;36m>> $(CONTAINER_TOOL) build --file=test/lab/Dockerfile --tag=$(TEST_LAB_IMG) .\e[0m\n"
@$(CONTAINER_TOOL) build --file=test/lab/Dockerfile --tag=$(TEST_LAB_IMG) .
docker-push-test-lab: FORCE docker-push-test-lab
@printf "\e[1;36m>> $(CONTAINER_TOOL) push $(TEST_LAB_IMG)\e[0m\n"
@$(CONTAINER_TOOL) push $(TEST_LAB_IMG)
ROOT_DIR := $(shell pwd)
DOCS_IMG ?= ironcore-dev/network-operator-docs:latest
run-docs:
@docker build -t $(DOCS_IMG) -f docs/Dockerfile docs --load
@docker run --rm --init -p 5173:5173 -v $(ROOT_DIR)/docs:/workspace -v /workspace/node_modules $(DOCS_IMG)
docs: install-crd-ref-docs
crd-ref-docs --source-path=./api --config=./hack/api-reference/config.yaml --renderer=markdown --output-path=./docs/api-reference/index.md
@$(SED) -i \
-e 's/#networkingmetalironcoredevv1alpha1/#networking-metal-ironcore-dev-v1alpha1/g' \
-e 's/#nxcisconetworkingmetalironcoredevv1alpha1/#nx-cisco-networking-metal-ironcore-dev-v1alpha1/g' \
-e 's/#xecisconetworkingmetalironcoredevv1alpha1/#xe-cisco-networking-metal-ironcore-dev-v1alpha1/g' \
-e 's/#xrcisconetworkingmetalironcoredevv1alpha1/#xr-cisco-networking-metal-ironcore-dev-v1alpha1/g' \
docs/api-reference/index.md
install-goimports: FORCE
@if ! hash goimports 2>/dev/null; then printf "\e[1;36m>> Installing goimports (this may take a while)...\e[0m\n"; go install golang.org/x/tools/cmd/goimports@latest; fi
install-golangci-lint: FORCE
@if ! hash golangci-lint 2>/dev/null; then printf "\e[1;36m>> Installing golangci-lint (this may take a while)...\e[0m\n"; go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest; fi
install-shellcheck: FORCE
@set -eou pipefail; if ! hash shellcheck 2>/dev/null; then printf "\e[1;36m>> Installing shellcheck...\e[0m\n"; SHELLCHECK_ARCH=$$(uname -m); if [[ "$$SHELLCHECK_ARCH" == "arm64" ]]; then SHELLCHECK_ARCH=aarch64; fi; SHELLCHECK_OS=$$(uname -s | tr '[:upper:]' '[:lower:]'); SHELLCHECK_VERSION="stable"; if command -v curl >/dev/null 2>&1; then GET="curl -sLo-"; elif command -v wget >/dev/null 2>&1; then GET="wget -O-"; else echo "Didn't find curl or wget to download shellcheck"; exit 2; fi; $$GET "https://github.com/koalaman/shellcheck/releases/download/$$SHELLCHECK_VERSION/shellcheck-$$SHELLCHECK_VERSION.$$SHELLCHECK_OS.$$SHELLCHECK_ARCH.tar.xz" | tar -Jxf -; BIN=$$(go env GOBIN); if [[ -z $$BIN ]]; then BIN=$$(go env GOPATH)/bin; fi; install -Dm755 shellcheck-$$SHELLCHECK_VERSION/shellcheck -t "$$BIN"; rm -rf shellcheck-$$SHELLCHECK_VERSION; fi
install-typos: FORCE
@set -eou pipefail; if ! hash typos 2>/dev/null; then printf "\e[1;36m>> Installing typos...\e[0m\n"; TYPOS_ARCH=$$(uname -m); if [[ "$$TYPOS_ARCH" == "arm64" ]]; then TYPOS_ARCH=aarch64; fi; if command -v curl >/dev/null 2>&1; then GET="curl $${GITHUB_TOKEN:+" -u \":$$GITHUB_TOKEN\""} -sLo-"; elif command -v wget >/dev/null 2>&1; then GET="wget $${GITHUB_TOKEN:+" --password \"$$GITHUB_TOKEN\""} -O-"; else echo "Didn't find curl or wget to download typos"; exit 2; fi; if command -v gh >/dev/null; then TYPOS_GET_RELEASE_JSON="gh api /repos/crate-ci/typos/releases"; else TYPOS_GET_RELEASE_JSON="$$GET https://api.github.com/repos/crate-ci/typos/releases"; fi; TYPOS_VERSION=$$($$TYPOS_GET_RELEASE_JSON | jq -r '.[0].name' ); if [[ $(UNAME_S) == Darwin ]]; then TYPOS_FILE="typos-$$TYPOS_VERSION-$$TYPOS_ARCH-apple-darwin.tar.gz"; elif [[ $(UNAME_S) == Linux ]]; then TYPOS_FILE="typos-$$TYPOS_VERSION-$$TYPOS_ARCH-unknown-linux-musl.tar.gz"; fi; mkdir -p typos; $$GET ""https://github.com/crate-ci/typos/releases/download/$$TYPOS_VERSION/$$TYPOS_FILE"" | tar -C typos -zxf -; BIN=$$(go env GOBIN); if [[ -z $$BIN ]]; then BIN=$$(go env GOPATH)/bin; fi; install -Dm755 typos/typos -t "$$BIN"; rm -rf typos/; fi
install-go-licence-detector: FORCE
@if ! hash go-licence-detector 2>/dev/null; then printf "\e[1;36m>> Installing go-licence-detector (this may take a while)...\e[0m\n"; go install go.elastic.co/go-licence-detector@latest; fi
install-addlicense: FORCE
@if ! hash addlicense 2>/dev/null; then printf "\e[1;36m>> Installing addlicense (this may take a while)...\e[0m\n"; go install github.com/google/addlicense@latest; fi
prepare-static-check: FORCE install-goimports install-golangci-lint install-shellcheck install-typos install-go-licence-detector install-addlicense
install-controller-gen: FORCE
@if ! hash controller-gen 2>/dev/null; then printf "\e[1;36m>> Installing controller-gen (this may take a while)...\e[0m\n"; go install sigs.k8s.io/controller-tools/cmd/controller-gen@latest; fi
install-setup-envtest: FORCE
@if ! hash setup-envtest 2>/dev/null; then printf "\e[1;36m>> Installing setup-envtest (this may take a while)...\e[0m\n"; go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest; fi
# To add additional flags or values (before the default ones), specify the variable in the environment, e.g. `GO_BUILDFLAGS='-tags experimental' make`.
# To override the default flags or values, specify the variable on the command line, e.g. `make GO_BUILDFLAGS='-tags experimental'`.
GO_BUILDFLAGS +=
GO_LDFLAGS +=
GO_TESTFLAGS +=
GO_TESTENV +=
GO_BUILDENV += CGO_ENABLED=0
# These definitions are overridable, e.g. to provide fixed version/commit values when
# no .git directory is present or to provide a fixed build date for reproducibility.
BININFO_VERSION ?= $(shell git describe --tags --always --abbrev=7)
BININFO_COMMIT_HASH ?= $(shell git rev-parse --verify HEAD)
BININFO_BUILD_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
build-all: build/network-operator
build/network-operator: FORCE generate
env $(GO_BUILDENV) go build $(GO_BUILDFLAGS) -ldflags '-s -w -X github.com/sapcc/go-api-declarations/bininfo.binName=network-operator -X github.com/sapcc/go-api-declarations/bininfo.version=$(BININFO_VERSION) -X github.com/sapcc/go-api-declarations/bininfo.commit=$(BININFO_COMMIT_HASH) -X github.com/sapcc/go-api-declarations/bininfo.buildDate=$(BININFO_BUILD_DATE) $(GO_LDFLAGS)' -o build/network-operator ./cmd
DESTDIR =
ifeq ($(UNAME_S),Darwin)
PREFIX = /usr/local
else
PREFIX = /usr
endif
install: FORCE build/network-operator
install -d -m 0755 "$(DESTDIR)$(PREFIX)/bin"
install -m 0755 build/network-operator "$(DESTDIR)$(PREFIX)/bin/network-operator"
# which packages to test with test runner
GO_TESTPKGS := $(shell go list -f '{{if or .TestGoFiles .XTestGoFiles}}{{.Dir}}{{end}}' ./... | grep -Ev '/test')
ifeq ($(GO_TESTPKGS),)
GO_TESTPKGS := ./...
endif
# which packages to measure coverage for
GO_COVERPKGS := $(shell go list ./... | grep -E '/internal')
# to get around weird Makefile syntax restrictions, we need variables containing nothing, a space and comma
null :=
space := $(null) $(null)
comma := ,
check: FORCE static-check build/cover.html build-all
@printf "\e[1;32m>> All checks successful.\e[0m\n"
generate: install-controller-gen
@printf "\e[1;36m>> controller-gen\e[0m\n"
@controller-gen crd rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
@controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
@controller-gen applyconfiguration:headerFile="hack/boilerplate.go.txt" paths="./..."
run-golangci-lint: FORCE install-golangci-lint
@printf "\e[1;36m>> golangci-lint\e[0m\n"
@golangci-lint config verify
@golangci-lint run
run-shellcheck: FORCE install-shellcheck
@printf "\e[1;36m>> shellcheck\e[0m\n"
@find . \( -path '*/docs/node_modules/*/*' -prune \) -o \( -path 'docs/node_modules/*' -prune \) -o -type f \( -name '*.bash' -o -name '*.ksh' -o -name '*.zsh' -o -name '*.sh' -o -name '*.shlib' \) -exec shellcheck {} +
run-typos: FORCE install-typos
@printf "\e[1;36m>> typos\e[0m\n"
@typos
build/cover.out: FORCE generate install-setup-envtest | build
@printf "\e[1;36m>> Running tests\e[0m\n"
KUBEBUILDER_ASSETS=$$(setup-envtest use 1.35 -p path) go run github.com/onsi/ginkgo/v2/ginkgo run --randomize-all -output-dir=build $(GO_BUILDFLAGS) -ldflags '-s -w -X github.com/sapcc/go-api-declarations/bininfo.binName=network-operator -X github.com/sapcc/go-api-declarations/bininfo.version=$(BININFO_VERSION) -X github.com/sapcc/go-api-declarations/bininfo.commit=$(BININFO_COMMIT_HASH) -X github.com/sapcc/go-api-declarations/bininfo.buildDate=$(BININFO_BUILD_DATE) $(GO_LDFLAGS)' -covermode=count -coverpkg=$(subst $(space),$(comma),$(GO_COVERPKGS)) $(GO_TESTFLAGS) $(GO_TESTPKGS)
@awk < build/coverprofile.out '$$1 != "mode:" { is_filename[$$1] = true; counts1[$$1]+=$$2; counts2[$$1]+=$$3 } END { for (filename in is_filename) { printf "%s %d %d\n", filename, counts1[filename], counts2[filename]; } }' | sort | $(SED) '1s/^/mode: count\n/' > $@
build/cover.html: build/cover.out
@printf "\e[1;36m>> go tool cover > build/cover.html\e[0m\n"
@go tool cover -html $< -o $@
check-addlicense: FORCE install-addlicense
@printf "\e[1;36m>> addlicense --check\e[0m\n"
@addlicense --check -- $(patsubst $(shell awk '$$1 == "module" {print $$2}' go.mod)%,.%/*.go,$(shell go list ./...))
check-license-headers: FORCE check-addlicense
__static-check: FORCE run-shellcheck run-golangci-lint check-dependency-licenses check-license-headers
static-check: FORCE
@$(MAKE) --keep-going --no-print-directory __static-check
build:
@mkdir $@
tidy-deps: FORCE
go mod tidy
go mod verify
license-headers: FORCE install-addlicense
@printf "\e[1;36m>> addlicense (for license headers on source code files)\e[0m\n"
@printf "%s\0" $(patsubst $(shell awk '$$1 == "module" {print $$2}' go.mod)%,.%/*.go,$(shell go list ./...)) | $(XARGS) -0 -I{} bash -c 'year="$$(grep 'Copyright' {} | head -n1 | grep -E -o '"'"'[0-9]{4}(-[0-9]{4})?'"'"')"; if [[ -z "$$year" ]]; then year=$$(date +%Y); fi; gawk -i inplace '"'"'{if (display) {print} else {!/^\/\*/ && !/^\*/}}; {if (!display && $$0 ~ /^(package |$$)/) {display=1} else { }}'"'"' {}; addlicense -c "SAP SE or an SAP affiliate company and IronCore contributors" -s=only -y "$$year" -- {}; $(SED) -i '"'"'1s+// Copyright +// SPDX-FileCopyrightText: +'"'"' {}; '
@printf "\e[1;36m>> reuse annotate (for license headers on other files)\e[0m\n"
@reuse lint -j | jq -r '.non_compliant.missing_licensing_info[]' | sed '/\<vendor\>/d' | $(XARGS) reuse annotate -c 'SAP SE or an SAP affiliate company and IronCore contributors' -l Apache-2.0 --skip-unrecognised
@printf "\e[1;36m>> reuse download --all\e[0m\n"
@reuse download --all
@printf "\e[1;35mPlease review the changes. If *.license files were generated, consider instructing go-makefile-maker to add overrides to REUSE.toml instead.\e[0m\n"
check-dependency-licenses: FORCE install-go-licence-detector
@printf "\e[1;36m>> go-licence-detector\e[0m\n"
@go list -m -mod=readonly -json all | go-licence-detector -includeIndirect -rules .license-scan-rules.json -overrides .license-scan-overrides.jsonl
goimports: FORCE install-goimports
@printf "\e[1;36m>> goimports -w -local https://github.com/ironcore-dev/network-operator\e[0m\n"
@goimports -w -local github.com/ironcore-dev/network-operator $(patsubst $(shell awk '$$1 == "module" {print $$2}' go.mod)%,.%/*.go,$(shell go list ./...))
clean: FORCE
git clean -dxf build
vars: FORCE
@printf "BININFO_BUILD_DATE=$(BININFO_BUILD_DATE)\n"
@printf "BININFO_COMMIT_HASH=$(BININFO_COMMIT_HASH)\n"
@printf "BININFO_VERSION=$(BININFO_VERSION)\n"
@printf "DESTDIR=$(DESTDIR)\n"
@printf "GO_BUILDENV=$(GO_BUILDENV)\n"
@printf "GO_BUILDFLAGS=$(GO_BUILDFLAGS)\n"
@printf "GO_COVERPKGS=$(GO_COVERPKGS)\n"
@printf "GO_LDFLAGS=$(GO_LDFLAGS)\n"
@printf "GO_TESTFLAGS=$(GO_TESTFLAGS)\n"
@printf "GO_TESTPKGS=$(GO_TESTPKGS)\n"
@printf "MAKE=$(MAKE)\n"
@printf "MAKE_VERSION=$(MAKE_VERSION)\n"
@printf "PREFIX=$(PREFIX)\n"
@printf "SED=$(SED)\n"
@printf "UNAME_S=$(UNAME_S)\n"
@printf "XARGS=$(XARGS)\n"
help: FORCE
@printf "\n"
@printf "\e[1mUsage:\e[0m\n"
@printf " make \e[36m<target>\e[0m\n"
@printf "\n"
@printf "\e[1mGeneral\e[0m\n"
@printf " \e[36mvars\e[0m Display values of relevant Makefile variables.\n"
@printf " \e[36mhelp\e[0m Display this help.\n"
@printf "\n"
@printf "\e[1mPrepare\e[0m\n"
@printf " \e[36minstall-goimports\e[0m Install goimports required by goimports/static-check\n"
@printf " \e[36minstall-golangci-lint\e[0m Install golangci-lint required by run-golangci-lint/static-check\n"
@printf " \e[36minstall-shellcheck\e[0m Install shellcheck required by run-shellcheck/static-check\n"
@printf " \e[36minstall-typos\e[0m Install typos required by run-typos/static-check\n"
@printf " \e[36minstall-go-licence-detector\e[0m Install-go-licence-detector required by check-dependency-licenses/static-check\n"
@printf " \e[36minstall-addlicense\e[0m Install addlicense required by check-license-headers/license-headers/static-check\n"
@printf " \e[36mprepare-static-check\e[0m Install any tools required by static-check. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
@printf " \e[36minstall-controller-gen\e[0m Install controller-gen required by static-check and build-all. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
@printf " \e[36minstall-setup-envtest\e[0m Install setup-envtest required by check. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
@printf "\n"
@printf "\e[1mBuild\e[0m\n"
@printf " \e[36mbuild-all\e[0m Build all binaries.\n"
@printf " \e[36mbuild/network-operator\e[0m Build network-operator.\n"
@printf " \e[36minstall\e[0m Install all binaries. This option understands the conventional 'DESTDIR' and 'PREFIX' environment variables for choosing install locations.\n"
@printf "\n"
@printf "\e[1mTest\e[0m\n"
@printf " \e[36mcheck\e[0m Run the test suite (unit tests and golangci-lint).\n"
@printf " \e[36mgenerate\e[0m Generate code for Kubernetes CRDs and deepcopy.\n"
@printf " \e[36mrun-golangci-lint\e[0m Install and run golangci-lint. Installing is used in CI, but you should probably install golangci-lint using your package manager.\n"
@printf " \e[36mrun-shellcheck\e[0m Install and run shellcheck. Installing is used in CI, but you should probably install shellcheck using your package manager.\n"
@printf " \e[36mrun-typos\e[0m Check for spelling errors using typos.\n"
@printf " \e[36mbuild/cover.out\e[0m Run tests and generate coverage report.\n"
@printf " \e[36mbuild/cover.html\e[0m Generate an HTML file with source code annotations from the coverage report.\n"
@printf " \e[36mcheck-addlicense\e[0m Check license headers in all non-vendored .go files with addlicense.\n"
@printf " \e[36mcheck-license-headers\e[0m Run static code checks\n"
@printf " \e[36mstatic-check\e[0m Run static code checks\n"
@printf "\n"
@printf "\e[1mDevelopment\e[0m\n"
@printf " \e[36mtidy-deps\e[0m Run go mod tidy and go mod verify.\n"
@printf " \e[36mlicense-headers\e[0m Add (or overwrite) license headers on all non-vendored source code files.\n"
@printf " \e[36mcheck-dependency-licenses\e[0m Check all dependency licenses using go-licence-detector.\n"
@printf " \e[36mgoimports\e[0m Run goimports on all non-vendored .go files\n"
@printf " \e[36mclean\e[0m Run git clean.\n"
.PHONY: FORCE