-
Notifications
You must be signed in to change notification settings - Fork 487
Expand file tree
/
Copy pathMakefile
More file actions
419 lines (370 loc) · 17.4 KB
/
Makefile
File metadata and controls
419 lines (370 loc) · 17.4 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
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
include embedded-bins/Makefile.variables
include inttest/Makefile.variables
include hack/tools/Makefile.variables
ifndef HOST_ARCH
HOST_HARDWARE := $(shell uname -m)
ifneq (, $(filter $(HOST_HARDWARE), aarch64 arm64))
HOST_ARCH := arm64
else ifneq (, $(filter $(HOST_HARDWARE), armv8l armv7l arm))
HOST_ARCH := arm
else ifneq (, $(filter $(HOST_HARDWARE), riscv64))
HOST_ARCH := riscv64
else
ifeq (, $(filter $(HOST_HARDWARE), x86_64 amd64 x64))
$(warning unknown machine hardware name $(HOST_HARDWARE), assuming amd64)
endif
HOST_ARCH := amd64
endif
endif
ifeq ($(OS),Windows_NT)
CYGPATH := $(shell cygpath --version >/dev/null 2>&1 && echo cygpath)
cygpath = $(if $(CYGPATH),$(shell '$(CYGPATH)' -- '$(1)'),$(1))
PATHSEP := $(if $(CYGPATH),:,;)
else
cygpath = $(1)
PATHSEP := :
endif
FIND ?= find
DOCKER ?= docker
K0S_GO_BUILD_CACHE ?= build/cache
GO_SRCS := $(shell $(FIND) . -type f -name "*.go" -not -path "./$(K0S_GO_BUILD_CACHE)/*" -not -path "./inttest/*" -not -name "*_test.go" -not -name "zz_generated*")
GO_CHECK_UNIT_DIRS := . ./cmd/... ./pkg/... ./internal/... ./static/... ./hack/...
# Disable Docker build integration if DOCKER is set to the empty string.
ifeq ($(DOCKER),)
GO_ENV_REQUISITES ?=
GO_ENV ?= PATH='$(call cygpath,$(abspath $(K0S_GO_BUILD_CACHE))/go/bin)$(PATHSEP)'"$$PATH" \
GOBIN="$(abspath $(K0S_GO_BUILD_CACHE))/go/bin" \
GOCACHE="$(abspath $(K0S_GO_BUILD_CACHE))/go/build" \
GOMODCACHE="$(abspath $(K0S_GO_BUILD_CACHE))/go/mod"
GO ?= $(GO_ENV) go
else
GO_ENV_REQUISITES ?= .k0sbuild.docker-image.k0s
GO_ENV ?= $(DOCKER) run --rm \
-v '$(realpath $(K0S_GO_BUILD_CACHE))':/run/k0s-build \
-v '$(CURDIR)':/go/src/github.com/k0sproject/k0s \
-w /go/src/github.com/k0sproject/k0s \
-e GOOS \
-e CGO_ENABLED \
-e CGO_CFLAGS \
-e GOARCH \
-e XDG_CACHE_HOME=/run/k0s-build \
--user $(BUILD_UID):$(BUILD_GID) \
$(DOCKER_RUN_OPTS) -- '$(shell cat .k0sbuild.docker-image.k0s)'
GO ?= $(GO_ENV) go
endif
# EMBEDDED_BINS_BUILDMODE can be either:
# docker builds the binaries in docker
# none does not embed any binaries
EMBEDDED_BINS_BUILDMODE ?= docker
# k0s runs on linux even if it's built on mac or windows
TARGET_OS ?= linux
BUILD_UID ?= $(shell id -u)
BUILD_GID ?= $(shell id -g)
BUILD_GO_TAGS ?= osusergo
BUILD_GO_FLAGS = -tags=$(subst $(space),$(comma),$(BUILD_GO_TAGS)) -buildvcs=false
BUILD_CGO_CFLAGS :=
BUILD_GO_LDFLAGS_EXTRA :=
DEBUG ?= false
VERSION ?= $(shell git describe --tags 2>/dev/null || printf v%s-dev+k0s '$(kubernetes_version)')
ifeq ($(DEBUG), false)
BUILD_GO_FLAGS += -trimpath
LD_FLAGS ?= -w -s
endif
# https://reproducible-builds.org/docs/source-date-epoch/#makefile
# https://reproducible-builds.org/docs/source-date-epoch/#git
SOURCE_DATE_EPOCH ?= $(shell git log -1 --pretty=%ct 2>/dev/null || date -u +%s)
BUILD_DATE_FMT = %Y-%m-%dT%H:%M:%SZ
BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" "+$(BUILD_DATE_FMT)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" "+$(BUILD_DATE_FMT)" 2>/dev/null || date -u "+$(BUILD_DATE_FMT)")
LD_FLAGS += -X github.com/k0sproject/k0s/pkg/build.Version=$(VERSION)
LD_FLAGS += -X github.com/k0sproject/k0s/pkg/build.RuncVersion=$(runc_version)
LD_FLAGS += -X github.com/k0sproject/k0s/pkg/build.ContainerdVersion=$(containerd_version)
LD_FLAGS += -X github.com/k0sproject/k0s/pkg/build.KubernetesVersion=$(kubernetes_version)
LD_FLAGS += -X github.com/k0sproject/k0s/pkg/build.KineVersion=$(kine_version)
LD_FLAGS += -X github.com/k0sproject/k0s/pkg/build.EtcdVersion=$(etcd_version)
LD_FLAGS += -X github.com/k0sproject/k0s/pkg/build.KonnectivityVersion=$(konnectivity_version)
LD_FLAGS += -X "github.com/k0sproject/k0s/pkg/build.EulaNotice=$(EULA_NOTICE)"
LD_FLAGS += -X github.com/k0sproject/k0s/pkg/telemetry.segmentToken=$(SEGMENT_TOKEN)
LD_FLAGS += -X k8s.io/component-base/version.gitVersion=v$(kubernetes_version)
LD_FLAGS += -X k8s.io/component-base/version.gitMajor=$(word 1,$(subst ., ,$(kubernetes_version)))
LD_FLAGS += -X k8s.io/component-base/version.gitMinor=$(word 2,$(subst ., ,$(kubernetes_version)))
LD_FLAGS += -X k8s.io/component-base/version.buildDate=$(BUILD_DATE)
LD_FLAGS += -X k8s.io/component-base/version.gitCommit=not_available
LD_FLAGS += -X github.com/containerd/containerd/v2/version.Version=$(containerd_version)
ifeq ($(EMBEDDED_BINS_BUILDMODE), docker)
ifeq ($(TARGET_OS),linux)
LD_FLAGS += -X github.com/containerd/containerd/v2/version.Revision=$(shell ./embedded-bins/staging/linux/bin/containerd --version | awk '{print $$4}')
endif
endif
LD_FLAGS += $(BUILD_GO_LDFLAGS_EXTRA)
GOLANG_IMAGE ?= $(golang_buildimage)
# https://www.gnu.org/software/make/manual/make.html#index-spaces_002c-in-variable-values
nullstring :=
space := $(nullstring) # space now holds a single space
comma := ,
.DELETE_ON_ERROR:
.PHONY: build
ifeq ($(TARGET_OS),windows)
build: k0s.exe
else
BUILD_GO_LDFLAGS_EXTRA = -extldflags=-static
build: k0s
endif
.PHONY: all
all: k0s k0s.exe
$(K0S_GO_BUILD_CACHE):
mkdir -p -- '$@'
.k0sbuild.docker-image.k0s: build/Dockerfile embedded-bins/Makefile.variables | $(K0S_GO_BUILD_CACHE)
$(DOCKER) build --progress=plain --iidfile '$@' \
--build-arg BUILDKIT_DOCKERFILE_CHECK=skip=InvalidDefaultArgInFrom \
--build-arg BUILDIMAGE=$(GOLANG_IMAGE) \
-t k0sbuild.docker-image.k0s - <build/Dockerfile
go.sum: go.mod $(GO_ENV_REQUISITES)
$(GO) mod tidy && touch -c -- '$@'
# List of all the custom APIs that k0s defines.
api_group_versions := $(foreach path,$(wildcard pkg/apis/*/v*/doc.go),$(path:pkg/apis/%/doc.go=%))
# Declare the requisites for the generators operating on API group versions.
api_group_version_targets := .controller-gen.stamp zz_generated.register.go
$(foreach gv,$(api_group_versions),$(eval $(foreach t,$(api_group_version_targets),pkg/apis/$(gv)/$(t)): $$(shell $(FIND) pkg/apis/$(gv)/ -maxdepth 1 -type f -name "*.go" -not -name "*_test.go" -not -name "zz_generated*")))
# Run controller-gen for each API group version.
controller_gen_targets := $(foreach gv,$(api_group_versions),pkg/apis/$(gv)/.controller-gen.stamp)
codegen_targets := $(controller_gen_targets)
$(controller_gen_targets): $(GO_ENV_REQUISITES) hack/tools/boilerplate.go.txt hack/tools/Makefile.variables
rm -rf 'static/_crds/$(dir $(@:pkg/apis/%/.controller-gen.stamp=%))'
gendir="$$(mktemp -d .controller-gen.tmp.XXXXXX)" \
&& trap "rm -rf -- $$gendir" INT EXIT \
&& CGO_ENABLED=0 $(GO) run sigs.k8s.io/controller-tools/cmd/controller-gen@v$(controller-tools_version) \
paths="./$(dir $@)..." \
object:headerFile=hack/tools/boilerplate.go.txt output:object:dir="$$gendir" \
crd output:crd:dir='static/_crds/$(dir $(@:pkg/apis/%/.controller-gen.stamp=%))' \
&& mv -f -- "$$gendir"/zz_generated.deepcopy.go '$(dir $@).'
touch -- '$@'
# Run register-gen for each API group version.
register_gen_targets := $(foreach gv,$(api_group_versions),pkg/apis/$(gv)/zz_generated.register.go)
codegen_targets += $(register_gen_targets)
$(register_gen_targets): $(GO_ENV_REQUISITES) hack/tools/boilerplate.go.txt embedded-bins/Makefile.variables
CGO_ENABLED=0 $(GO) run k8s.io/code-generator/cmd/register-gen@v$(kubernetes_version:1.%=0.%) \
--go-header-file=hack/tools/boilerplate.go.txt \
--output-file='_$(notdir $@).tmp' \
'github.com/k0sproject/k0s/$(dir $@)' || { \
ret=$$?; \
rm -f -- '$(dir $@)_$(notdir $@).tmp'; \
exit $$ret; \
}
mv -- '$(dir $@)_$(notdir $@).tmp' '$@'
# Generate the k0s client-go clientset based on all custom API group versions.
clientset_input_dirs := $(foreach gv,$(api_group_versions),pkg/apis/$(gv))
codegen_targets += pkg/client/clientset/.client-gen.stamp
pkg/client/clientset/.client-gen.stamp: $(shell $(FIND) $(clientset_input_dirs) -type f -name "*.go" -not -name "*_test.go" -not -name "zz_generated*")
pkg/client/clientset/.client-gen.stamp: $(GO_ENV_REQUISITES) hack/tools/boilerplate.go.txt embedded-bins/Makefile.variables
gendir="$$(mktemp -d .client-gen.tmp.XXXXXX)" \
&& trap "rm -rf -- $$gendir" INT EXIT \
&& CGO_ENABLED=0 $(GO) run k8s.io/code-generator/cmd/client-gen@v$(kubernetes_version:1.%=0.%) \
--go-header-file=hack/tools/boilerplate.go.txt \
--input-base='' \
--input=$(subst $(space),$(comma),$(clientset_input_dirs:%=github.com/k0sproject/k0s/%)) \
--output-pkg=github.com/k0sproject/k0s/pkg/client \
--clientset-name=clientset \
--output-dir="$$gendir/out" \
&& { [ ! -e pkg/client/clientset ] || mv -- pkg/client/clientset "$$gendir/old"; } \
&& mv -f -- "$$gendir/out/clientset" pkg/client/.
touch -- '$@'
ifeq ($(EMBEDDED_BINS_BUILDMODE),none)
BUILD_GO_TAGS += noembedbins
else
codegen_targets += pkg/assets/zz_generated_offsets_$(TARGET_OS).go
zz_os = $(patsubst pkg/assets/zz_generated_offsets_%.go,%,$@)
pkg/assets/zz_generated_offsets_linux.go: .bins.linux.stamp
pkg/assets/zz_generated_offsets_windows.go: .bins.windows.stamp
pkg/assets/zz_generated_offsets_linux.go pkg/assets/zz_generated_offsets_windows.go: $(GO_ENV_REQUISITES) go.sum
GOOS=${GOHOSTOS} $(GO) run -tags=hack hack/gen-bindata/cmd/main.go -o bindata_$(zz_os) -pkg assets \
-gofile pkg/assets/zz_generated_offsets_$(zz_os).go \
-prefix embedded-bins/staging/$(zz_os)/ embedded-bins/staging/$(zz_os)/bin
endif
k0s: TARGET_OS = linux
k0s: BUILD_GO_CGO_ENABLED = 0
k0s.exe: TARGET_OS = windows
k0s.exe: BUILD_GO_CGO_ENABLED = 0
k0s.exe k0s: $(GO_ENV_REQUISITES) go.sum $(codegen_targets) $(GO_SRCS) $(shell find static/manifests/calico static/manifests/windows -type f)
rm -f -- '$@'
CGO_ENABLED=$(BUILD_GO_CGO_ENABLED) CGO_CFLAGS='$(BUILD_CGO_CFLAGS)' GOOS=$(TARGET_OS) $(GO) build $(BUILD_GO_FLAGS) -ldflags='$(LD_FLAGS)' -o '$@' main.go
ifneq ($(EMBEDDED_BINS_BUILDMODE),none)
cat -- bindata_$(TARGET_OS) >>$@
endif
@printf '\n%s size: %s\n\n' '$@' "$$(du -sh -- $@ | cut -f1)"
.bins.windows.stamp .bins.linux.stamp: embedded-bins/Makefile.variables
$(MAKE) -C embedded-bins \
TARGET_OS=$(patsubst .bins.%.stamp,%,$@) \
SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH)
touch $@
.PHONY: codegen
codegen: $(codegen_targets)
# bindata contains the parts of codegen which aren't version controlled.
.PHONY: bindata
bindata:
ifneq ($(EMBEDDED_BINS_BUILDMODE),none)
bindata: pkg/assets/zz_generated_offsets_$(TARGET_OS).go
endif
.PHONY: lint-copyright
lint-copyright:
hack/copyright.sh
.PHONY: lint-invisible-unicode
lint-invisible-unicode:
@set -eu; \
echo Checking tracked files for invisible Unicode format characters ...; \
{ \
git grep -I --line-number --perl-regexp \
-e '\x{00A0}' `# U+00A0 NO-BREAK SPACE` \
-e '\x{00AD}' `# U+00AD SOFT HYPHEN` \
-e '\x{1680}' `# U+1680 OGHAM SPACE MARK` \
-e '\x{2000}' `# U+2000 EN QUAD` \
-e '\x{2001}' `# U+2001 EM QUAD` \
-e '\x{2002}' `# U+2002 EN SPACE` \
-e '\x{2003}' `# U+2003 EM SPACE` \
-e '\x{2004}' `# U+2004 THREE-PER-EM SPACE` \
-e '\x{2005}' `# U+2005 FOUR-PER-EM SPACE` \
-e '\x{2006}' `# U+2006 SIX-PER-EM SPACE` \
-e '\x{2007}' `# U+2007 FIGURE SPACE` \
-e '\x{2008}' `# U+2008 PUNCTUATION SPACE` \
-e '\x{2009}' `# U+2009 THIN SPACE` \
-e '\x{200A}' `# U+200A HAIR SPACE` \
-e '\x{200B}' `# U+200B ZERO WIDTH SPACE` \
-e '\x{200C}' `# U+200C ZERO WIDTH NON-JOINER` \
-e '\x{200D}' `# U+200D ZERO WIDTH JOINER` \
-e '\x{200E}' `# U+200E LEFT-TO-RIGHT MARK` \
-e '\x{200F}' `# U+200F RIGHT-TO-LEFT MARK` \
-e '\x{2028}' `# U+2028 LINE SEPARATOR` \
-e '\x{2029}' `# U+2029 PARAGRAPH SEPARATOR` \
-e '\x{202A}' `# U+202A LEFT-TO-RIGHT EMBEDDING` \
-e '\x{202B}' `# U+202B RIGHT-TO-LEFT EMBEDDING` \
-e '\x{202C}' `# U+202C POP DIRECTIONAL FORMATTING` \
-e '\x{202D}' `# U+202D LEFT-TO-RIGHT OVERRIDE` \
-e '\x{202E}' `# U+202E RIGHT-TO-LEFT OVERRIDE` \
-e '\x{202F}' `# U+202F NARROW NO-BREAK SPACE` \
-e '\x{205F}' `# U+205F MEDIUM MATHEMATICAL SPACE` \
-e '\x{2060}' `# U+2060 WORD JOINER` \
-e '\x{2066}' `# U+2066 LEFT-TO-RIGHT ISOLATE` \
-e '\x{2067}' `# U+2067 RIGHT-TO-LEFT ISOLATE` \
-e '\x{2068}' `# U+2068 FIRST STRONG ISOLATE` \
-e '\x{2069}' `# U+2069 POP DIRECTIONAL ISOLATE` \
-e '\x{3000}' `# U+3000 IDEOGRAPHIC SPACE` \
-e '\x{FEFF}' `# U+FEFF ZERO WIDTH NO-BREAK SPACE / BOM` \
|| { [ $$? -eq 1 ] || echo ~; }; \
} | { \
numMatches=0; \
while IFS= read -r match; do \
[ "$$match" != ~ ] || exit 1; \
[ -z "$$match" ] && continue; \
numMatches=$$((numMatches + 1)); \
file="$${match%%:*}"; \
rest="$${match#*:}"; \
line="$${rest%%:*}"; \
echo "::error file=$$file,line=$$line,title=Invisible Unicode format character::Found a disallowed invisible Unicode character. Remove it."; \
done; \
if [ "$$numMatches" -eq 0 ]; then \
echo No invisible Unicode format characters found.; \
else \
exit 1; \
fi \
}
.PHONY: lint-go
lint-go: GOLANGCI_LINT_FLAGS ?=
lint-go: $(GO_ENV_REQUISITES) go.sum bindata
CGO_ENABLED=0 $(GO) install github.com/golangci/golangci-lint/v$(word 1,$(subst ., ,$(golangci-lint_version)))/cmd/golangci-lint@v$(golangci-lint_version)
GOLANGCI_LINT_CACHE='$(abspath $(K0S_GO_BUILD_CACHE))/golangci-lint' GO_CFLAGS='$(BUILD_CGO_CFLAGS)' $(GO_ENV) golangci-lint run --verbose --build-tags=$(subst $(space),$(comma),$(BUILD_GO_TAGS)) $(GOLANGCI_LINT_FLAGS) $(GO_LINT_DIRS)
.PHONY: lint
lint: lint-copyright lint-go
airgap-images.txt: k0s $(GO_ENV_REQUISITES)
$(GO_ENV) ./k0s airgap list-images --all > '$@'
airgap-image-bundle-linux-amd64.tar: TARGET_PLATFORM := linux/amd64
airgap-image-bundle-linux-arm64.tar: TARGET_PLATFORM := linux/arm64
airgap-image-bundle-linux-arm.tar: TARGET_PLATFORM := linux/arm/v7
airgap-image-bundle-linux-riscv64.tar: TARGET_PLATFORM := linux/riscv64
airgap-image-bundle-linux-amd64.tar \
airgap-image-bundle-linux-arm64.tar \
airgap-image-bundle-linux-arm.tar \
airgap-image-bundle-linux-riscv64.tar: k0s airgap-images.txt
set -- $$(cat airgap-images.txt) && \
$(GO_ENV) ./k0s airgap bundle-artifacts --concurrency=1 -v --platform='$(TARGET_PLATFORM)' -o '$@' "$$@"
ipv6-test-images.txt: $(GO_ENV_REQUISITES) embedded-bins/Makefile.variables hack/gen-test-images-list/main.go
{ \
echo "docker.io/library/nginx:1.29.7-alpine"; \
echo "docker.io/curlimages/curl:8.18.0"; \
echo "docker.io/library/alpine:$(alpine_version)"; \
echo "docker.io/sonobuoy/sonobuoy:v$(sonobuoy_version)"; \
echo "registry.k8s.io/conformance:v$(kubernetes_version)"; \
$(GO) run -tags=hack ./hack/gen-test-images-list; \
} >'$@'
ipv6-test-image-bundle-linux-amd64.tar: TARGET_PLATFORM := linux/amd64
ipv6-test-image-bundle-linux-arm64.tar: TARGET_PLATFORM := linux/arm64
ipv6-test-image-bundle-linux-arm.tar: TARGET_PLATFORM := linux/arm/v7
ipv6-test-image-bundle-linux-riscv64.tar: TARGET_PLATFORM := linux/riscv64
ipv6-test-image-bundle-linux-amd64.tar \
ipv6-test-image-bundle-linux-arm64.tar \
ipv6-test-image-bundle-linux-arm.tar \
ipv6-test-image-bundle-linux-riscv64.tar: k0s ipv6-test-images.txt
set -- $$(cat ipv6-test-images.txt) && \
$(GO_ENV) ./k0s airgap bundle-artifacts -v --platform='$(TARGET_PLATFORM)' -o '$@' "$$@"
.PHONY: $(smoketests)
$(air_gapped_smoketests) $(ipv6_smoketests): airgap-image-bundle-linux-$(HOST_ARCH).tar
$(ipv6_smoketests): ipv6-test-image-bundle-linux-$(HOST_ARCH).tar
$(smoketests): k0s
$(MAKE) -C inttest \
K0S_IMAGES_BUNDLE='$(CURDIR)/airgap-image-bundle-linux-$(HOST_ARCH).tar' \
K0S_EXTRA_IMAGES_BUNDLE='$(CURDIR)/ipv6-test-image-bundle-linux-$(HOST_ARCH).tar' \
$@
.PHONY: smoketests
smoketests: $(smoketests)
.PHONY: check-unit
ifneq (, $(filter $(HOST_ARCH), arm riscv64))
check-unit: GO_TEST_RACE ?=
else
check-unit: GO_TEST_RACE ?= -race
endif
check-unit: BUILD_GO_TAGS += hack
check-unit: $(GO_ENV_REQUISITES) go.sum bindata
CGO_CFLAGS='$(BUILD_CGO_CFLAGS)' $(GO) test -tags=$(subst $(space),$(comma),$(BUILD_GO_TAGS)) $(GO_TEST_RACE) -ldflags='$(LD_FLAGS)' `$(GO) list -tags=$(subst $(space),$(comma),$(BUILD_GO_TAGS)) $(GO_CHECK_UNIT_DIRS)`
.PHONY: clean-gocache
clean-gocache:
-chmod -R u+w -- '$(K0S_GO_BUILD_CACHE)/go/mod'
rm -rf -- '$(K0S_GO_BUILD_CACHE)/go'
.PHONY: clean-docker-image
clean-docker-image: IID_FILES = .k0sbuild.docker-image.k0s
clean-docker-image:
$(clean-iid-files)
.PHONY: clean-airgap-image-bundles
clean-airgap-image-bundles:
-rm airgap-images.txt
-rm airgap-image-bundle-linux-amd64.tar airgap-image-bundle-linux-arm64.tar airgap-image-bundle-linux-arm.tar airgap-image-bundle-linux-riscv64.tar
.PHONY: clean
clean: clean-gocache clean-docker-image clean-airgap-image-bundles
-rm -f pkg/assets/zz_generated_offsets_*.go k0s k0s.exe .bins.*stamp bindata*
-rm -rf $(K0S_GO_BUILD_CACHE)
-find pkg/apis -type f -name .controller-gen.stamp -delete
-rm pkg/client/clientset/.client-gen.stamp
-rm -f hack/.copyright.stamp
-rm -f spdx.json
-$(MAKE) -C docs clean
-$(MAKE) -C embedded-bins clean
-$(MAKE) -C inttest clean
.PHONY: docs
docs:
$(MAKE) -C docs
.PHONY: docs-serve-dev
docs-serve-dev: DOCS_DEV_PORT ?= 8000
docs-serve-dev:
$(MAKE) -C docs .docker-image.serve-dev.stamp
$(DOCKER) run --rm \
-e PYTHONPATH=/k0s/docs/mkdocs_modules \
-e K0S_VERSION=$(VERSION) \
-v "$(CURDIR):/k0s:ro" \
-p '$(DOCS_DEV_PORT):8000' \
$(DOCKER_RUN_OPTS) k0sdocs.docker-image.serve-dev
spdx.json: syft.yaml go.mod .bins.$(TARGET_OS).stamp
$(DOCKER) run --rm \
-v '$(CURDIR)/syft.yaml':/k0s/syft.yaml:ro \
-v '$(CURDIR)/go.mod':/k0s/go.mod:ro \
-v '$(CURDIR)/embedded-bins/staging/$(TARGET_OS)/bin':/k0s/bin:ro \
-w /k0s \
$(DOCKER_RUN_OPTS) docker.io/anchore/syft:v1.42.3 \
--source-name k0s --source-version '$(VERSION)' \
-c syft.yaml -o spdx-json@2.2 . >'$@'