github.com/cilium/cilium@v1.16.2/Makefile (about) 1 # Copyright Authors of Cilium 2 # SPDX-License-Identifier: Apache-2.0 3 4 ##@ Default 5 all: precheck build postcheck ## Default make target that perform precheck -> build -> postcheck 6 @echo "Build finished." 7 8 ##@ Build, Install and Test 9 debug: export NOOPT=1 ## Builds Cilium by disabling inlining, compiler optimizations and without stripping debug symbols, useful for debugging. 10 debug: export NOSTRIP=1 11 debug: all 12 13 include Makefile.defs 14 15 SUBDIRS_CILIUM_CONTAINER := cilium-dbg daemon cilium-health bugtool tools/mount tools/sysctlfix plugins/cilium-cni 16 SUBDIR_OPERATOR_CONTAINER := operator 17 SUBDIR_RELAY_CONTAINER := hubble-relay 18 19 ifdef LIBNETWORK_PLUGIN 20 SUBDIRS_CILIUM_CONTAINER += plugins/cilium-docker 21 endif 22 23 # Add the ability to override variables 24 -include Makefile.override 25 26 # List of subdirectories used for global "make build", "make clean", etc 27 SUBDIRS := $(SUBDIRS_CILIUM_CONTAINER) $(SUBDIR_OPERATOR_CONTAINER) plugins tools $(SUBDIR_RELAY_CONTAINER) bpf 28 29 # Filter out any directories where the parent directory is also present, to avoid 30 # building or cleaning a subdirectory twice. 31 # For example: The directory "tools" is transformed into a match pattern "tools/%", 32 # which is then used to filter out items such as "tools/mount" and "tools/sysctlfx" 33 SUBDIRS := $(filter-out $(foreach dir,$(SUBDIRS),$(dir)/%),$(SUBDIRS)) 34 35 # Space-separated list of Go packages to test, equivalent to 'go test' package patterns. 36 # Because is treated as a Go package pattern, the special '...' sequence is supported, 37 # meaning 'all subpackages of the given package'. 38 TESTPKGS ?= ./... 39 40 GOTEST_BASE := -timeout 600s 41 GOTEST_COVER_OPTS += -coverprofile=coverage.out 42 BENCH_EVAL := "." 43 BENCH ?= $(BENCH_EVAL) 44 BENCHFLAGS_EVAL := -bench=$(BENCH) -run=^$ -benchtime=10s 45 BENCHFLAGS ?= $(BENCHFLAGS_EVAL) 46 SKIP_KVSTORES ?= "false" 47 SKIP_K8S_CODE_GEN_CHECK ?= "true" 48 SKIP_CUSTOMVET_CHECK ?= "false" 49 50 JOB_BASE_NAME ?= cilium_test 51 52 TEST_LDFLAGS=-ldflags "-X github.com/cilium/cilium/pkg/kvstore.consulDummyAddress=https://consul:8443 \ 53 -X github.com/cilium/cilium/pkg/kvstore.etcdDummyAddress=http://etcd:4002" 54 55 TEST_UNITTEST_LDFLAGS= 56 57 build: $(SUBDIRS) ## Builds all the components for Cilium by executing make in the respective sub directories. 58 59 build-container: ## Builds components required for cilium-agent container. 60 for i in $(SUBDIRS_CILIUM_CONTAINER); do $(MAKE) $(SUBMAKEOPTS) -C $$i all; done 61 62 build-container-operator: ## Builds components required for cilium-operator container. 63 $(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) all 64 65 build-container-operator-generic: ## Builds components required for a cilium-operator generic variant container. 66 $(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) cilium-operator-generic 67 68 build-container-operator-aws: ## Builds components required for a cilium-operator aws variant container. 69 $(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) cilium-operator-aws 70 71 build-container-operator-azure: ## Builds components required for a cilium-operator azure variant container. 72 $(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) cilium-operator-azure 73 74 build-container-operator-alibabacloud: ## Builds components required for a cilium-operator alibabacloud variant container. 75 $(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) cilium-operator-alibabacloud 76 77 build-container-hubble-relay: 78 $(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_RELAY_CONTAINER) all 79 80 $(SUBDIRS): force ## Execute default make target(make all) for the provided subdirectory. 81 @ $(MAKE) $(SUBMAKEOPTS) -C $@ all 82 83 tests-privileged: ## Run Go tests including ones that require elevated privileges. 84 @$(ECHO_CHECK) running privileged tests... 85 PRIVILEGED_TESTS=true PATH=$(PATH):$(ROOT_DIR)/bpf $(GO_TEST) -p 1 $(TEST_LDFLAGS) \ 86 $(TESTPKGS) $(GOTEST_BASE) $(GOTEST_COVER_OPTS) | $(GOTEST_FORMATTER) 87 $(MAKE) generate-cov 88 89 start-kvstores: ## Start running kvstores (etcd and consul containers) for integration tests. 90 ifeq ($(SKIP_KVSTORES),"false") 91 @echo Starting key-value store containers... 92 -$(QUIET)$(CONTAINER_ENGINE) rm -f "cilium-etcd-test-container" 2> /dev/null 93 $(QUIET)$(CONTAINER_ENGINE) run -d \ 94 -e ETCD_UNSUPPORTED_ARCH=$(GOARCH) \ 95 --name "cilium-etcd-test-container" \ 96 -p 4002:4001 \ 97 $(ETCD_IMAGE) \ 98 etcd -name etcd0 \ 99 -advertise-client-urls http://0.0.0.0:4001 \ 100 -listen-client-urls http://0.0.0.0:4001 \ 101 -listen-peer-urls http://0.0.0.0:2380 \ 102 -initial-cluster-token etcd-cluster-1 \ 103 -initial-cluster-state new 104 -$(QUIET)$(CONTAINER_ENGINE) rm -f "cilium-consul-test-container" 2> /dev/null 105 $(QUIET)rm -rf /tmp/cilium-consul-certs 106 $(QUIET)mkdir /tmp/cilium-consul-certs 107 $(QUIET)cp $(CURDIR)/test/consul/* /tmp/cilium-consul-certs 108 $(QUIET)chmod -R a+rX /tmp/cilium-consul-certs 109 $(QUIET)$(CONTAINER_ENGINE) run -d \ 110 --name "cilium-consul-test-container" \ 111 -p 8501:8443 \ 112 -e 'CONSUL_LOCAL_CONFIG={"skip_leave_on_interrupt": true, "disable_update_check": true}' \ 113 -v /tmp/cilium-consul-certs:/cilium-consul/ \ 114 $(CONSUL_IMAGE) \ 115 agent -client=0.0.0.0 -server -bootstrap-expect 1 -config-file=/cilium-consul/consul-config.json 116 endif 117 118 stop-kvstores: ## Forcefully removes running kvstore components (etcd and consul containers) for integration tests. 119 ifeq ($(SKIP_KVSTORES),"false") 120 $(QUIET)$(CONTAINER_ENGINE) rm -f "cilium-etcd-test-container" 121 $(QUIET)$(CONTAINER_ENGINE) rm -f "cilium-consul-test-container" 122 $(QUIET)rm -rf /tmp/cilium-consul-certs 123 endif 124 125 generate-cov: ## Generate HTML coverage report at coverage-all.html. 126 -@# Remove generated code from coverage 127 $(QUIET) grep -Ev '(^github.com/cilium/cilium/api/v1)|(generated.deepcopy.go)|(^github.com/cilium/cilium/pkg/k8s/client/)' \ 128 coverage.out > coverage.out.tmp 129 $(QUIET)$(GO) tool cover -html=coverage.out.tmp -o=coverage-all.html 130 $(QUIET) rm coverage.out.tmp 131 @rmdir ./daemon/1 ./daemon/1_backup 2> /dev/null || true 132 133 integration-tests: start-kvstores ## Run Go tests including ones that are marked as integration tests. 134 $(QUIET) $(MAKE) $(SUBMAKEOPTS) -C test/bpf/ 135 @$(ECHO_CHECK) running integration tests... 136 INTEGRATION_TESTS=true $(GO_TEST) $(TEST_UNITTEST_LDFLAGS) $(TESTPKGS) $(GOTEST_BASE) $(GOTEST_COVER_OPTS) | $(GOTEST_FORMATTER) 137 $(MAKE) generate-cov 138 $(MAKE) stop-kvstores 139 140 bench: start-kvstores ## Run benchmarks for Cilium integration-tests in the repository. 141 $(GO_TEST) $(TEST_UNITTEST_LDFLAGS) $(GOTEST_BASE) $(BENCHFLAGS) $(TESTPKGS) 142 $(MAKE) stop-kvstores 143 144 bench-privileged: ## Run benchmarks for privileged tests. 145 PRIVILEGED_TESTS=true $(GO_TEST) $(TEST_UNITTEST_LDFLAGS) $(GOTEST_BASE) $(BENCHFLAGS) $(TESTPKGS) 146 147 clean-tags: ## Remove all the tags files from the repository. 148 @$(ECHO_CLEAN) tags 149 @-rm -f cscope.out cscope.in.out cscope.po.out cscope.files tags 150 151 .PHONY: cscope.files 152 cscope.files: ## Generate cscope.files with the list of all files to generate ctags for. 153 @# Argument to -f must be double-quoted since shell removes backslashes that appear 154 @# before newlines. Otherwise, backslashes will appear in the output file. 155 @go list -f "{{ \$$p := .ImportPath }} \ 156 {{- range .GoFiles }}{{ printf \"%s/%s\n\" \$$p . }}{{ end }} \ 157 {{- range .TestGoFiles }}{{ printf \"%s/%s\n\" \$$p . }}{{ end }}" ./... \ 158 | sed 's#github.com/cilium/cilium/##g' | sort | uniq > cscope.files 159 160 @echo "$(BPF_SRCFILES)" | sed 's/ /\n/g' | sort >> cscope.files 161 162 tags: cscope.files ## Generate tags for Go and BPF source files. 163 @ctags -L cscope.files 164 cscope -R -b -q 165 166 clean-container: ## Perform `make clean` for each component required in cilium-agent container. 167 -$(QUIET) for i in $(SUBDIRS_CILIUM_CONTAINER); do $(MAKE) $(SUBMAKEOPTS) -C $$i clean; done 168 169 clean: ## Perform overall cleanup for Cilium. 170 -$(QUIET) for i in $(SUBDIRS); do $(MAKE) $(SUBMAKEOPTS) -C $$i clean; done 171 172 veryclean: ## Perform complete cleanup for container engine images(including build cache). 173 -$(QUIET) $(CONTAINER_ENGINE) image prune -af 174 -$(QUIET) $(CONTAINER_ENGINE) builder prune -af 175 176 install-bpf: ## Copies over the BPF source files from bpf/ to /var/lib/cilium/bpf/ 177 $(QUIET)$(INSTALL) -m 0750 -d $(DESTDIR)$(LOCALSTATEDIR)/lib/cilium 178 -rm -rf $(DESTDIR)$(LOCALSTATEDIR)/lib/cilium/bpf/* 179 $(foreach bpfsrc,$(BPF_SRCFILES), $(INSTALL) -D -m 0644 $(bpfsrc) $(DESTDIR)$(LOCALSTATEDIR)/lib/cilium/$(bpfsrc);) 180 181 install: install-bpf ## Performs install for all the Cilium sub components (daemon, operator, relay etc.) 182 $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR) 183 for i in $(SUBDIRS); do $(MAKE) $(SUBMAKEOPTS) -C $$i install; done 184 185 install-container: install-bpf ## Performs install for all components required for cilium-agent container. 186 $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR) 187 for i in $(SUBDIRS_CILIUM_CONTAINER); do $(MAKE) $(SUBMAKEOPTS) -C $$i install; done 188 189 install-container-binary: install-bpf ## Install binaries for all components required for cilium-agent container. 190 $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR) 191 for i in $(SUBDIRS_CILIUM_CONTAINER); do $(MAKE) $(SUBMAKEOPTS) -C $$i install-binary; done 192 193 install-bash-completion: ## Install bash completion for all components required for cilium-agent container. 194 $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR) 195 for i in $(SUBDIRS_CILIUM_CONTAINER); do $(MAKE) $(SUBMAKEOPTS) -C $$i install-bash-completion; done 196 197 install-container-binary-operator: ## Install binaries for all components required for cilium-operator container. 198 $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR) 199 $(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) install 200 201 install-container-binary-operator-generic: ## Install binaries for all components required for cilium-operator generic variant container. 202 $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR) 203 $(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) install-generic 204 205 install-container-binary-operator-aws: ## Install binaries for all components required for cilium-operator aws variant container. 206 $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR) 207 $(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) install-aws 208 209 install-container-binary-operator-azure: ## Install binaries for all components required for cilium-operator azure variant container. 210 $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR) 211 $(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) install-azure 212 213 install-container-binary-operator-alibabacloud: ## Install binaries for all components required for cilium-operator alibabacloud variant container. 214 $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR) 215 $(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_OPERATOR_CONTAINER) install-alibabacloud 216 217 install-container-binary-hubble-relay: 218 $(QUIET)$(INSTALL) -m 0755 -d $(DESTDIR)$(BINDIR) 219 $(MAKE) $(SUBMAKEOPTS) -C $(SUBDIR_RELAY_CONTAINER) install-binary 220 221 # Workaround for not having git in the build environment 222 # Touch the file only if needed 223 GIT_VERSION: force 224 @if [ "$(GIT_VERSION)" != "`cat 2>/dev/null GIT_VERSION`" ] ; then echo "$(GIT_VERSION)" >GIT_VERSION; fi 225 226 check_deps: 227 @$(CILIUM_CLI) --help > /dev/null 2>&1 || ( echo "ERROR: '$(CILIUM_CLI)' not found. Please install it." && exit 1) 228 229 include Makefile.kind 230 231 -include Makefile.docker 232 233 manifests: ## Generate K8s manifests e.g. CRD, RBAC etc. 234 contrib/scripts/k8s-manifests-gen.sh 235 236 .PHONY: generate-apis 237 generate-apis: generate-api generate-health-api generate-hubble-api generate-operator-api generate-kvstoremesh-api 238 239 generate-api: api/v1/openapi.yaml ## Generate cilium-agent client, model and server code from openapi spec. 240 @$(ECHO_GEN)api/v1/openapi.yaml 241 -$(QUIET)$(SWAGGER) generate server -s server -a restapi \ 242 -t api/v1 \ 243 -f api/v1/openapi.yaml \ 244 --default-scheme=unix \ 245 -C api/v1/cilium-server.yml \ 246 -r hack/spdx-copyright-header.txt 247 -$(QUIET)$(SWAGGER) generate client -a restapi \ 248 -t api/v1 \ 249 -f api/v1/openapi.yaml \ 250 -r hack/spdx-copyright-header.txt 251 @# sort goimports automatically 252 -$(QUIET)$(GO) run golang.org/x/tools/cmd/goimports -w ./api/v1/client ./api/v1/models ./api/v1/server 253 254 generate-health-api: api/v1/health/openapi.yaml ## Generate cilium-health client, model and server code from openapi spec. 255 @$(ECHO_GEN)api/v1/health/openapi.yaml 256 -$(QUIET)$(SWAGGER) generate server -s server -a restapi \ 257 -t api/v1 \ 258 -t api/v1/health/ \ 259 -f api/v1/health/openapi.yaml \ 260 --default-scheme=unix \ 261 -C api/v1/cilium-server.yml \ 262 -r hack/spdx-copyright-header.txt 263 -$(QUIET)$(SWAGGER) generate client -a restapi \ 264 -t api/v1 \ 265 -t api/v1/health/ \ 266 -f api/v1/health/openapi.yaml \ 267 -r hack/spdx-copyright-header.txt 268 @# sort goimports automatically 269 -$(QUIET)$(GO) run golang.org/x/tools/cmd/goimports -w ./api/v1/health 270 271 generate-operator-api: api/v1/operator/openapi.yaml ## Generate cilium-operator client, model and server code from openapi spec. 272 @$(ECHO_GEN)api/v1/operator/openapi.yaml 273 -$(QUIET)$(SWAGGER) generate server -s server -a restapi \ 274 -t api/v1 \ 275 -t api/v1/operator/ \ 276 -f api/v1/operator/openapi.yaml \ 277 --default-scheme=http \ 278 -C api/v1/cilium-server.yml \ 279 -r hack/spdx-copyright-header.txt 280 -$(QUIET)$(SWAGGER) generate client -a restapi \ 281 -t api/v1 \ 282 -t api/v1/operator/ \ 283 -f api/v1/operator/openapi.yaml \ 284 -r hack/spdx-copyright-header.txt 285 @# sort goimports automatically 286 -$(QUIET)$(GO) run golang.org/x/tools/cmd/goimports -w ./api/v1/operator 287 288 generate-kvstoremesh-api: api/v1/kvstoremesh/openapi.yaml ## Generate kvstoremesh client, model and server code from openapi spec. 289 @$(ECHO_GEN)api/v1/kvstoremesh/openapi.yaml 290 -$(QUIET)$(SWAGGER) generate server -s server -a restapi \ 291 -t api/v1 \ 292 -t api/v1/kvstoremesh/ \ 293 -f api/v1/kvstoremesh/openapi.yaml \ 294 --default-scheme=http \ 295 -C api/v1/cilium-server.yml \ 296 -r hack/spdx-copyright-header.txt 297 -$(QUIET)$(SWAGGER) generate client -a restapi \ 298 -t api/v1 \ 299 -t api/v1/kvstoremesh/ \ 300 -f api/v1/kvstoremesh/openapi.yaml \ 301 -r hack/spdx-copyright-header.txt 302 @# sort goimports automatically 303 -$(QUIET)$(GO) run golang.org/x/tools/cmd/goimports -w ./api/v1/kvstoremesh 304 305 generate-hubble-api: api/v1/flow/flow.proto api/v1/peer/peer.proto api/v1/observer/observer.proto api/v1/relay/relay.proto ## Generate hubble proto Go sources. 306 $(QUIET) $(MAKE) $(SUBMAKEOPTS) -C api/v1 307 308 define generate_deepequal 309 $(GO) run github.com/cilium/deepequal-gen \ 310 --input-dirs $(subst $(space),$(comma),$(1)) \ 311 --go-header-file "$$PWD/hack/custom-boilerplate.go.txt" \ 312 --output-file-base zz_generated.deepequal \ 313 --output-base $(2) 314 endef 315 316 define generate_k8s_protobuf 317 $(GO) install k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo && \ 318 $(GO) install golang.org/x/tools/cmd/goimports && \ 319 $(GO) run k8s.io/code-generator/cmd/go-to-protobuf \ 320 --apimachinery-packages='-k8s.io/apimachinery/pkg/util/intstr,$\ 321 -k8s.io/apimachinery/pkg/api/resource,$\ 322 -k8s.io/apimachinery/pkg/runtime/schema,$\ 323 -k8s.io/apimachinery/pkg/runtime,$\ 324 -k8s.io/apimachinery/pkg/apis/meta/v1,$\ 325 -k8s.io/apimachinery/pkg/apis/meta/v1beta1'\ 326 --drop-embedded-fields="github.com/cilium/cilium/pkg/k8s/slim/k8s/apis/meta/v1.TypeMeta" \ 327 --proto-import="$$PWD" \ 328 --proto-import="$$PWD/vendor" \ 329 --proto-import="$$PWD/tools/protobuf" \ 330 --packages=$(subst $(newline),$(comma),$(1)) \ 331 --go-header-file "$$PWD/hack/custom-boilerplate.go.txt" \ 332 --output-dir=$$GOPATH/src 333 endef 334 335 define K8S_PROTO_PACKAGES 336 github.com/cilium/cilium/pkg/k8s/slim/k8s/api/core/v1 337 github.com/cilium/cilium/pkg/k8s/slim/k8s/api/discovery/v1 338 github.com/cilium/cilium/pkg/k8s/slim/k8s/api/discovery/v1beta1 339 github.com/cilium/cilium/pkg/k8s/slim/k8s/api/networking/v1 340 github.com/cilium/cilium/pkg/k8s/slim/k8s/apis/apiextensions/v1 341 github.com/cilium/cilium/pkg/k8s/slim/k8s/apis/meta/v1 342 github.com/cilium/cilium/pkg/k8s/slim/k8s/apis/meta/v1beta1 343 github.com/cilium/cilium/pkg/k8s/slim/k8s/apis/util/intstr 344 endef 345 346 .PHONY: generate-k8s-api-local 347 generate-k8s-api-local: 348 $(ASSERT_CILIUM_MODULE) 349 350 $(eval TMPDIR := $(shell mktemp -d -t cilium.tmpXXXXXXXX)) 351 352 $(QUIET) $(call generate_k8s_protobuf,${K8S_PROTO_PACKAGES},"$(TMPDIR)") 353 354 $(eval DEEPEQUAL_PACKAGES := $(shell grep "\+deepequal-gen" -l -r --include \*.go --exclude-dir 'vendor' . | xargs dirname {} | sort | uniq | grep -x -v '.' | sed 's|\.\/|github.com/cilium/cilium\/|g')) 355 $(QUIET) $(call generate_deepequal,${DEEPEQUAL_PACKAGES},"$(TMPDIR)") 356 357 $(QUIET) contrib/scripts/k8s-code-gen.sh "$(TMPDIR)" 358 359 $(QUIET) rm -rf "$(TMPDIR)" 360 361 .PHONY: generate-k8s-api 362 generate-k8s-api: ## Generate Cilium k8s API client, deepcopy and deepequal Go sources. 363 RUN_AS_NONROOT=1 contrib/scripts/builder.sh \ 364 $(MAKE) -C /go/src/github.com/cilium/cilium/ generate-k8s-api-local 365 366 check-k8s-clusterrole: ## Ensures there is no diff between preflight's clusterrole and runtime's clusterrole. 367 ./contrib/scripts/check-preflight-clusterrole.sh 368 369 ##@ Development 370 vps: ## List all the running vagrant VMs. 371 VBoxManage list runningvms 372 373 reload: ## Reload cilium-agent and cilium-docker systemd service after installing built binaries. 374 sudo systemctl stop cilium cilium-docker 375 sudo $(MAKE) install 376 sudo systemctl start cilium cilium-docker 377 sleep 6 378 cilium status 379 380 release: ## Perform a Git release for Cilium. 381 @echo "Visit https://github.com/cilium/release/issues/new/choose to initiate the release process." 382 383 gofmt: ## Run gofmt on Go source files in the repository. 384 $(QUIET)$(GO) fmt ./... 385 386 govet: ## Run govet on Go source files in the repository. 387 @$(ECHO_CHECK) vetting all packages... 388 $(QUIET) $(GO_VET) ./... 389 390 golangci-lint: ## Run golangci-lint 391 ifneq (,$(findstring $(GOLANGCILINT_WANT_VERSION:v%=%),$(GOLANGCILINT_VERSION))) 392 @$(ECHO_CHECK) golangci-lint $(GOLANGCI_LINT_ARGS) 393 $(QUIET) golangci-lint run $(GOLANGCI_LINT_ARGS) 394 else 395 $(QUIET) $(CONTAINER_ENGINE) run --rm -v `pwd`:/app -w /app docker.io/golangci/golangci-lint:$(GOLANGCILINT_WANT_VERSION)@$(GOLANGCILINT_IMAGE_SHA) golangci-lint run $(GOLANGCI_LINT_ARGS) 396 endif 397 398 golangci-lint-fix: ## Run golangci-lint to automatically fix warnings 399 $(QUIET)$(MAKE) golangci-lint GOLANGCI_LINT_ARGS="--fix" 400 401 lint: golangci-lint 402 403 lint-fix: golangci-lint-fix 404 405 logging-subsys-field: ## Validate logrus subsystem field for logs in Go source code. 406 @$(ECHO_CHECK) contrib/scripts/check-logging-subsys-field.sh 407 $(QUIET) contrib/scripts/check-logging-subsys-field.sh 408 409 check-microk8s: ## Validate if microk8s is ready to install cilium. 410 @$(ECHO_CHECK) microk8s is ready... 411 $(QUIET)microk8s.status >/dev/null \ 412 || (echo "Error: Microk8s is not running" && exit 1) 413 414 LOCAL_IMAGE_TAG=local 415 microk8s: export DOCKER_REGISTRY=localhost:32000 416 microk8s: export LOCAL_AGENT_IMAGE=$(DOCKER_REGISTRY)/$(DOCKER_DEV_ACCOUNT)/cilium-dev:$(LOCAL_IMAGE_TAG) 417 microk8s: export LOCAL_OPERATOR_IMAGE=$(DOCKER_REGISTRY)/$(DOCKER_DEV_ACCOUNT)/operator:$(LOCAL_IMAGE_TAG) 418 microk8s: check-microk8s ## Build cilium-dev docker image and import to microk8s 419 $(QUIET)$(MAKE) dev-docker-image DOCKER_IMAGE_TAG=$(LOCAL_IMAGE_TAG) 420 @echo " DEPLOY image to microk8s ($(LOCAL_AGENT_IMAGE))" 421 $(QUIET)./contrib/scripts/microk8s-import.sh $(LOCAL_AGENT_IMAGE) 422 $(QUIET)$(MAKE) dev-docker-operator-image DOCKER_IMAGE_TAG=$(LOCAL_IMAGE_TAG) 423 @echo " DEPLOY image to microk8s ($(LOCAL_OPERATOR_IMAGE))" 424 $(QUIET)./contrib/scripts/microk8s-import.sh $(LOCAL_OPERATOR_IMAGE) 425 426 precheck: logging-subsys-field ## Peform build precheck for the source code. 427 ifeq ($(SKIP_K8S_CODE_GEN_CHECK),"false") 428 @$(ECHO_CHECK) contrib/scripts/check-k8s-code-gen.sh 429 $(QUIET) contrib/scripts/check-k8s-code-gen.sh 430 endif 431 @$(ECHO_CHECK) contrib/scripts/check-fmt.sh 432 $(QUIET) contrib/scripts/check-fmt.sh 433 @$(ECHO_CHECK) contrib/scripts/check-log-newlines.sh 434 $(QUIET) contrib/scripts/check-log-newlines.sh 435 @$(ECHO_CHECK) contrib/scripts/check-test-tags.sh 436 $(QUIET) contrib/scripts/check-test-tags.sh 437 @$(ECHO_CHECK) contrib/scripts/lock-check.sh 438 $(QUIET) contrib/scripts/lock-check.sh 439 @$(ECHO_CHECK) contrib/scripts/check-viper.sh 440 $(QUIET) contrib/scripts/check-viper.sh 441 ifeq ($(SKIP_CUSTOMVET_CHECK),"false") 442 @$(ECHO_CHECK) contrib/scripts/custom-vet-check.sh 443 $(QUIET) contrib/scripts/custom-vet-check.sh 444 endif 445 @$(ECHO_CHECK) contrib/scripts/check-time.sh 446 $(QUIET) contrib/scripts/check-time.sh 447 @$(ECHO_CHECK) contrib/scripts/check-go-testdata.sh 448 $(QUIET) contrib/scripts/check-go-testdata.sh 449 @$(ECHO_CHECK) contrib/scripts/check-source-info.sh 450 $(QUIET) contrib/scripts/check-source-info.sh 451 @$(ECHO_CHECK) contrib/scripts/check-xfrmstate.sh 452 $(QUIET) contrib/scripts/check-xfrmstate.sh 453 @$(ECHO_CHECK) contrib/scripts/check-legacy-header-guard.sh 454 $(QUIET) contrib/scripts/check-legacy-header-guard.sh 455 @$(ECHO_CHECK) contrib/scripts/check-logrus.sh 456 $(QUIET) contrib/scripts/check-logrus.sh 457 458 pprof-heap: ## Get Go pprof heap profile. 459 $(QUIET)$(GO) tool pprof http://localhost:6060/debug/pprof/heap 460 461 pprof-profile: ## Get Go pprof profile. 462 $(QUIET)$(GO) tool pprof http://localhost:6060/debug/pprof/profile 463 464 pprof-block: ## Get Go pprof block profile. 465 $(QUIET)$(GO) tool pprof http://localhost:6060/debug/pprof/block 466 467 pprof-trace-5s: ## Get Go pprof trace for a duration of 5 seconds. 468 curl http://localhost:6060/debug/pprof/trace?seconds=5 469 470 pprof-mutex: ## Get Go pprof mutex profile. 471 $(QUIET)$(GO) tool pprof http://localhost:6060/debug/pprof/mutex 472 473 update-authors: ## Update AUTHORS file for Cilium repository. 474 @echo "Updating AUTHORS file..." 475 @echo "The following people, in alphabetical order, have either authored or signed" > AUTHORS 476 @echo "off on commits in the Cilium repository:" >> AUTHORS 477 @echo "" >> AUTHORS 478 @contrib/scripts/extract_authors.sh >> AUTHORS 479 @cat .authors.aux >> AUTHORS 480 481 generate-crd-docs: ## Generate CRD List for documentation 482 $(QUIET)$(GO) run ./tools/crdlistgen 483 484 test-docs: ## Build HTML documentation. 485 $(MAKE) -C Documentation html 486 487 render-docs: ## Run server with live preview to render documentation. 488 $(MAKE) -C Documentation live-preview 489 490 manpages: ## Generate manpage for Cilium CLI. 491 -rm -r man 492 mkdir -p man 493 cilium cmdman -d man 494 495 install-manpages: ## Install manpages the Cilium CLI. 496 cp man/* /usr/local/share/man/man1/ 497 mandb 498 499 postcheck: build ## Run Cilium build postcheck (update-cmdref, build documentation etc.). 500 $(QUIET) SKIP_BUILD=true $(MAKE) $(SUBMAKEOPTS) -C Documentation check 501 502 licenses-all: ## Generate file with all the License from dependencies. 503 @$(GO) run ./tools/licensegen > LICENSE.all || ( rm -f LICENSE.all ; false ) 504 505 dev-doctor: ## Run Cilium dev-doctor to validate local development environment. 506 $(QUIET)$(GO) version 2>/dev/null || ( echo "go not found, see https://golang.org/doc/install" ; false ) 507 $(QUIET)$(GO) run ./tools/dev-doctor 508 509 help: ## Display help for the Makefile, from https://www.thapaliya.com/en/writings/well-documented-makefiles/. 510 $(call print_help_from_makefile) 511 @# There is also a list of target we have to manually put the information about. 512 @# These are templated targets. 513 $(call print_help_line,"docker-cilium-image","Build cilium-agent docker image") 514 $(call print_help_line,"dev-docker-image","Build cilium-agent development docker image") 515 $(call print_help_line,"docker-plugin-image","Build cilium-docker plugin image") 516 $(call print_help_line,"docker-hubble-relay-image","Build hubble-relay docker image") 517 $(call print_help_line,"docker-clustermesh-apiserver-image","Build docker image for Cilium clustermesh APIServer") 518 $(call print_help_line,"docker-operator-image","Build cilium-operator docker image") 519 $(call print_help_line,"docker-operator-*-image","Build platform specific cilium-operator images(alibabacloud, aws, azure, generic)") 520 $(call print_help_line,"docker-*-image-unstripped","Build unstripped version of above docker images(cilium, hubble-relay, operator etc.)") 521 522 .PHONY: help clean clean-container dev-doctor force generate-api generate-health-api generate-operator-api generate-kvstoremesh-api generate-hubble-api install licenses-all veryclean run_bpf_tests run-builder 523 force :; 524 525 BPF_TEST_FILE ?= "" 526 527 run_bpf_tests: ## Build and run the BPF unit tests using the cilium-builder container image. 528 DOCKER_ARGS=--privileged contrib/scripts/builder.sh \ 529 "make" "-j$(shell nproc)" "-C" "bpf/tests/" "run" "BPF_TEST_FILE=$(BPF_TEST_FILE)" 530 531 run-builder: ## Drop into a shell inside a container running the cilium-builder image. 532 DOCKER_ARGS=-it contrib/scripts/builder.sh bash