From f793bdb23ed675203ebe8e781a2b3e79476c020f Mon Sep 17 00:00:00 2001 From: Prajyot-Parab Date: Sun, 5 Dec 2021 11:49:47 +0000 Subject: [PATCH] refactor and update Makefile Signed-off-by: Prajyot-Parab --- Makefile | 707 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 363 insertions(+), 344 deletions(-) diff --git a/Makefile b/Makefile index fe2f2173be62..bb84ebd35d6c 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ # limitations under the License. # If you update this file, please follow -# https://suva.sh/posts/well-documented-makefiles +# https://www.thapaliya.com/en/writings/well-documented-makefiles/ # Ensure Make is run with bash shell as some syntax below is bash-specific SHELL:=/usr/bin/env bash @@ -131,163 +131,77 @@ LDFLAGS := $(shell hack/version.sh) all: test managers clusterctl -help: ## Display this help - @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[0-9A-Za-z_-]+:.*?##/ { printf " \033[36m%-45s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) +help: # Display this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n\nTargets:\n"} /^[0-9A-Za-z_-]+:.*?##/ { printf " \033[36m%-45s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) ## -------------------------------------- -## Testing -## -------------------------------------- - -ARTIFACTS ?= ${ROOT_DIR}/_artifacts - -KUBEBUILDER_ASSETS ?= $(shell $(SETUP_ENVTEST) use --use-env -p path $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION)) - -.PHONY: test -test: $(SETUP_ENVTEST) ## Run tests. - KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test ./... $(TEST_ARGS) - -.PHONY: test-verbose -test-verbose: ## Run tests with verbose settings. - $(MAKE) test TEST_ARGS="$(TEST_ARGS) -v" - -.PHONY: test-junit -test-junit: $(SETUP_ENVTEST) $(GOTESTSUM) ## Run tests with verbose setting and generate a junit report. - set +o errexit; (KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test -json ./... $(TEST_ARGS); echo $$? > $(ARTIFACTS)/junit.exitcode) | tee $(ARTIFACTS)/junit.stdout - $(GOTESTSUM) --junitfile $(ARTIFACTS)/junit.xml --raw-command cat $(ARTIFACTS)/junit.stdout - exit $$(cat $(ARTIFACTS)/junit.exitcode) - -.PHONY: test-cover -test-cover: ## Run tests with code coverage and code generate reports. - $(MAKE) test TEST_ARGS="$(TEST_ARGS) -coverprofile=out/coverage.out" - go tool cover -func=out/coverage.out -o out/coverage.txt - go tool cover -html=out/coverage.out -o out/coverage.html - -.PHONY: docker-build-e2e -docker-build-e2e: ## Rebuild all Cluster API provider images to be used in the e2e tests - make docker-build REGISTRY=gcr.io/k8s-staging-cluster-api PULL_POLICY=IfNotPresent - $(MAKE) -C $(CAPD_DIR) docker-build REGISTRY=gcr.io/k8s-staging-cluster-api PULL_POLICY=IfNotPresent - -.PHONY: test-e2e -test-e2e: ## Run the e2e tests - $(MAKE) -C $(TEST_DIR)/e2e run - -.PHONY: kind-cluster -kind-cluster: ## Create a new kind cluster designed for testing with Tilt - hack/kind-install-for-capd.sh - -## -------------------------------------- -## Binaries -## -------------------------------------- - -.PHONY: manager-core -manager-core: ## Build core manager binary - go build -trimpath -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/manager sigs.k8s.io/cluster-api - -.PHONY: manager-kubeadm-bootstrap -manager-kubeadm-bootstrap: ## Build kubeadm bootstrap manager - go build -trimpath -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/kubeadm-bootstrap-manager sigs.k8s.io/cluster-api/bootstrap/kubeadm - -.PHONY: manager-kubeadm-control-plane -manager-kubeadm-control-plane: ## Build kubeadm control plane manager - go build -trimpath -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/kubeadm-control-plane-manager sigs.k8s.io/cluster-api/controlplane/kubeadm - -.PHONY: managers -managers: ## Build all managers - $(MAKE) manager-core - $(MAKE) manager-kubeadm-bootstrap - $(MAKE) manager-kubeadm-control-plane - -.PHONY: clusterctl -clusterctl: ## Build clusterctl binary - go build -trimpath -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/clusterctl sigs.k8s.io/cluster-api/cmd/clusterctl - -$(SETUP_ENVTEST): $(TOOLS_DIR)/go.mod # Build setup-envtest from tools folder. - cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/setup-envtest sigs.k8s.io/controller-runtime/tools/setup-envtest - -$(CONTROLLER_GEN): $(TOOLS_DIR)/go.mod # Build controller-gen from tools folder. - cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen - -$(GOTESTSUM): $(TOOLS_DIR)/go.mod # Build gotestsum from tools folder. - cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/gotestsum gotest.tools/gotestsum - -$(CONVERSION_GEN): $(TOOLS_DIR)/go.mod - cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/conversion-gen k8s.io/code-generator/cmd/conversion-gen - -$(CONVERSION_VERIFIER): $(TOOLS_DIR)/go.mod - cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/conversion-verifier sigs.k8s.io/cluster-api/hack/tools/conversion-verifier - -$(GO_APIDIFF): $(TOOLS_DIR)/go.mod - cd $(TOOLS_DIR) && go build -tags=tools -o $(GO_APIDIFF_BIN) github.com/joelanford/go-apidiff - -$(ENVSUBST): $(TOOLS_DIR)/go.mod - cd $(TOOLS_DIR) && go build -tags=tools -o $(ENVSUBST_BIN) github.com/drone/envsubst/v2/cmd/envsubst - -$(YQ): $(TOOLS_DIR)/go.mod - cd $(TOOLS_DIR) && go build -tags=tools -o $(YQ_BIN) github.com/mikefarah/yq/v4 - -$(KPROMO): $(TOOLS_DIR)/go.mod - cd $(TOOLS_DIR) && go build -tags=tools -o $(KPROMO_BIN) sigs.k8s.io/promo-tools/v3/cmd/kpromo - -$(KUSTOMIZE): # Download kustomize using hack script into tools folder. - hack/ensure-kustomize.sh - -$(GOLANGCI_LINT): .github/workflows/golangci-lint.yml # Download golanci-lint using hack script into tools folder. - hack/ensure-golangci-lint.sh \ - -b $(TOOLS_DIR)/$(BIN_DIR) \ - $(shell cat .github/workflows/golangci-lint.yml | grep version | sed 's/.*version: //') - -envsubst: $(ENVSUBST) ## Build a local copy of envsubst. -kustomize: $(KUSTOMIZE) ## Build a local copy of kustomize. -setup-envtest: $(SETUP_ENVTEST) ## Build a local copy of setup-envtest. -controller-gen: $(CONTROLLER_GEN) ## Build a local copy of controller-gen. -conversion-gen: $(CONVERSION_GEN) ## Build a local copy of conversion-gen. -conversion-verifier: $(CONVERSION_VERIFIER) ## Build a local copy of conversion-verifier. -gotestsum: $(GOTESTSUM) ## Build a local copy of gotestsum. -yq: $(YQ) ## Build a local copy of yq. -kpromo: $(KPROMO) ## Build a local copy of kpromo. - -.PHONY: e2e-framework -e2e-framework: ## Builds the CAPI e2e framework - cd $(E2E_FRAMEWORK_DIR); go build ./... - -## -------------------------------------- -## Linting +## Generate / Manifests ## -------------------------------------- -.PHONY: lint -lint: $(GOLANGCI_LINT) ## Lint codebase - $(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS) - cd $(TEST_DIR); $(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS) - cd $(TOOLS_DIR); $(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS) +##@ generate: -.PHONY: lint-fix -lint-fix: $(GOLANGCI_LINT) ## Lint the codebase and run auto-fixers if supported by the linter. - GOLANGCI_LINT_EXTRA_ARGS=--fix $(MAKE) lint +ALL_GENERATE_MODULES = core kubeadm-bootstrap kubeadm-control-plane -apidiff: $(GO_APIDIFF) ## Check for API differences - $(GO_APIDIFF) $(shell git rev-parse origin/main) --print-compatible +.PHONY: generate +generate: ## Run all generate-manifests-*, generate-go-deepcopy-* and generate-go-conversions-* targets + $(MAKE) generate-manifests generate-go-deepcopy generate-go-conversions + $(MAKE) -C $(CAPD_DIR) generate -## -------------------------------------- -## Generate / Manifests -## -------------------------------------- +.PHONY: generate-manifests +generate-manifests: $(addprefix generate-manifests-,$(ALL_GENERATE_MODULES)) ## Run all generate-manifests-* targets -ALL_GENERATE_MODULES = core cabpk kcp +.PHONY: generate-manifests-core +generate-manifests-core: $(CONTROLLER_GEN) $(KUSTOMIZE) ## Generate manifests e.g. CRD, RBAC etc. for core + $(CONTROLLER_GEN) \ + paths=./api/... \ + paths=./controllers/... \ + paths=./internal/webhooks/... \ + paths=./$(EXP_DIR)/api/... \ + paths=./$(EXP_DIR)/internal/controllers/... \ + paths=./$(EXP_DIR)/addons/api/... \ + paths=./$(EXP_DIR)/addons/internal/controllers/... \ + crd:crdVersions=v1 \ + rbac:roleName=manager-role \ + output:crd:dir=./config/crd/bases \ + output:webhook:dir=./config/webhook \ + webhook + $(CONTROLLER_GEN) \ + paths=./cmd/clusterctl/api/... \ + crd:crdVersions=v1 \ + output:crd:dir=./cmd/clusterctl/config/crd/bases + $(KUSTOMIZE) build $(CLUSTERCTL_MANIFEST_DIR)/crd > $(CLUSTERCTL_MANIFEST_DIR)/manifest/clusterctl-api.yaml -.PHONY: generate -generate: ## Generate code - $(MAKE) generate-manifests generate-go generate-go-conversions - $(MAKE) -C $(CAPD_DIR) generate +.PHONY: generate-manifests-kubeadm-bootstrap +generate-manifests-kubeadm-bootstrap: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc. for kubeadm bootstrap + $(CONTROLLER_GEN) \ + paths=./bootstrap/kubeadm/api/... \ + paths=./bootstrap/kubeadm/internal/controllers/... \ + crd:crdVersions=v1 \ + rbac:roleName=manager-role \ + output:crd:dir=./bootstrap/kubeadm/config/crd/bases \ + output:rbac:dir=./bootstrap/kubeadm/config/rbac \ + output:webhook:dir=./bootstrap/kubeadm/config/webhook \ + webhook -.PHONY: generate-go -generate-go: ## Runs Go related generate targets - $(MAKE) $(addprefix generate-go-,$(ALL_GENERATE_MODULES)) +.PHONY: generate-manifests-kubeadm-control-plane +generate-manifests-kubeadm-control-plane: $(CONTROLLER_GEN) ## Generate manifests e.g. CRD, RBAC etc. for kubeadm control plane + $(CONTROLLER_GEN) \ + paths=./controlplane/kubeadm/api/... \ + paths=./controlplane/kubeadm/controllers/... \ + paths=./controlplane/kubeadm/internal/webhooks/... \ + crd:crdVersions=v1 \ + rbac:roleName=manager-role \ + output:crd:dir=./controlplane/kubeadm/config/crd/bases \ + output:rbac:dir=./controlplane/kubeadm/config/rbac \ + output:webhook:dir=./controlplane/kubeadm/config/webhook \ + webhook -.PHONY: generate-go-conversions -generate-go-conversions: ## Runs Go related generate targets for conversions - $(MAKE) $(addprefix generate-go-conversions-,$(ALL_GENERATE_MODULES)) +.PHONY: generate-go-deepcopy +generate-go-deepcopy: ## Run all generate-go-deepcopy-* targets + $(MAKE) $(addprefix generate-go-deepcopy-,$(ALL_GENERATE_MODULES)) -.PHONY: generate-go-core -generate-go-core: $(CONTROLLER_GEN) +.PHONY: generate-go-deepcopy-core +generate-go-deepcopy-core: $(CONTROLLER_GEN) ## Generate deepcopy go code for core $(CONTROLLER_GEN) \ object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \ paths=./api/... \ @@ -295,8 +209,25 @@ generate-go-core: $(CONTROLLER_GEN) paths=./$(EXP_DIR)/addons/api/... \ paths=./cmd/clusterctl/... +.PHONY: generate-go-deepcopy-kubeadm-bootstrap +generate-go-deepcopy-kubeadm-bootstrap: $(CONTROLLER_GEN) ## Generate deepcopy go code for kubeadm bootstrap + $(CONTROLLER_GEN) \ + object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \ + paths=./bootstrap/kubeadm/api/... \ + paths=./bootstrap/kubeadm/types/... + +.PHONY: generate-go-deepcopy-kubeadm-control-plane +generate-go-deepcopy-kubeadm-control-plane: $(CONTROLLER_GEN) ## Generate deepcopy go code for kubeadm control plane + $(CONTROLLER_GEN) \ + object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \ + paths=./controlplane/kubeadm/api/... + +.PHONY: generate-go-conversions +generate-go-conversions: ## Run all generate-go-conversions-* targets + $(MAKE) $(addprefix generate-go-conversions-,$(ALL_GENERATE_MODULES)) + .PHONY: generate-go-conversions-core -generate-go-conversions-core: $(CONVERSION_GEN) +generate-go-conversions-core: $(CONVERSION_GEN) ## Generate conversions go code for core $(MAKE) clean-generated-conversions SRC_DIRS="./api/v1alpha3,./$(EXP_DIR)/api/v1alpha3,./$(EXP_DIR)/addons/api/v1alpha3" $(MAKE) clean-generated-conversions SRC_DIRS="./api/v1alpha4,./$(EXP_DIR)/api/v1alpha4,./$(EXP_DIR)/addons/api/v1alpha4" $(CONVERSION_GEN) \ @@ -315,15 +246,8 @@ generate-go-conversions-core: $(CONVERSION_GEN) --output-file-base=zz_generated.conversion $(CONVERSION_GEN_OUTPUT_BASE) \ --go-header-file=./hack/boilerplate/boilerplate.generatego.txt -.PHONY: generate-go-cabpk -generate-go-cabpk: $(CONTROLLER_GEN) - $(CONTROLLER_GEN) \ - object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \ - paths=./bootstrap/kubeadm/api/... \ - paths=./bootstrap/kubeadm/types/... - -.PHONY: generate-go-conversions-cabpk -generate-go-conversions-cabpk: $(CONVERSION_GEN) +.PHONY: generate-go-conversions-kubeadm-bootstrap +generate-go-conversions-kubeadm-bootstrap: $(CONVERSION_GEN) ## Generate conversions go code for kubeadm bootstrap $(MAKE) clean-generated-conversions SRC_DIRS="./bootstrap/kubeadm/api" $(CONVERSION_GEN) \ --input-dirs=./bootstrap/kubeadm/api/v1alpha3 \ @@ -342,14 +266,8 @@ generate-go-conversions-cabpk: $(CONVERSION_GEN) --output-file-base=zz_generated.conversion $(CONVERSION_GEN_OUTPUT_BASE) \ --go-header-file=./hack/boilerplate/boilerplate.generatego.txt -.PHONY: generate-go-kcp -generate-go-kcp: $(CONTROLLER_GEN) - $(CONTROLLER_GEN) \ - object:headerFile=./hack/boilerplate/boilerplate.generatego.txt \ - paths=./controlplane/kubeadm/api/... - -.PHONY: generate-go-conversions-kcp -generate-go-conversions-kcp: $(CONVERSION_GEN) +.PHONY: generate-go-conversions-kubeadm-control-plane +generate-go-conversions-kubeadm-control-plane: $(CONVERSION_GEN) ## Generate conversions go code for kubeadm control plane $(MAKE) clean-generated-conversions SRC_DIRS="./controlplane/kubeadm/api" $(CONVERSION_GEN) \ --input-dirs=./controlplane/kubeadm/api/v1alpha3 \ @@ -362,82 +280,133 @@ generate-go-conversions-kcp: $(CONVERSION_GEN) --output-file-base=zz_generated.conversion $(CONVERSION_GEN_OUTPUT_BASE) \ --go-header-file=./hack/boilerplate/boilerplate.generatego.txt +.PHONY: diagrams +diagrams: ## Generate diagrams for *.plantuml files + $(MAKE) -C docs diagrams -.PHONY: generate-manifests -generate-manifests: $(addprefix generate-manifests-,$(ALL_GENERATE_MODULES)) ## Generate manifests e.g. CRD, RBAC etc. +## -------------------------------------- +## Lint / Verify +## -------------------------------------- -.PHONY: generate-manifests-core -generate-manifests-core: $(CONTROLLER_GEN) $(KUSTOMIZE) - $(CONTROLLER_GEN) \ - paths=./api/... \ - paths=./controllers/... \ - paths=./internal/webhooks/... \ - paths=./$(EXP_DIR)/api/... \ - paths=./$(EXP_DIR)/internal/controllers/... \ - paths=./$(EXP_DIR)/addons/api/... \ - paths=./$(EXP_DIR)/addons/internal/controllers/... \ - crd:crdVersions=v1 \ - rbac:roleName=manager-role \ - output:crd:dir=./config/crd/bases \ - output:webhook:dir=./config/webhook \ - webhook - $(CONTROLLER_GEN) \ - paths=./cmd/clusterctl/api/... \ - crd:crdVersions=v1 \ - output:crd:dir=./cmd/clusterctl/config/crd/bases - $(KUSTOMIZE) build $(CLUSTERCTL_MANIFEST_DIR)/crd > $(CLUSTERCTL_MANIFEST_DIR)/manifest/clusterctl-api.yaml +##@ lint and verify: -.PHONY: generate-manifests-cabpk -generate-manifests-cabpk: $(CONTROLLER_GEN) - $(CONTROLLER_GEN) \ - paths=./bootstrap/kubeadm/api/... \ - paths=./bootstrap/kubeadm/internal/controllers/... \ - crd:crdVersions=v1 \ - rbac:roleName=manager-role \ - output:crd:dir=./bootstrap/kubeadm/config/crd/bases \ - output:rbac:dir=./bootstrap/kubeadm/config/rbac \ - output:webhook:dir=./bootstrap/kubeadm/config/webhook \ - webhook +.PHONY: modules +modules: ## Run go mod tidy to ensure modules are up to date + go mod tidy + cd $(TOOLS_DIR); go mod tidy + cd $(TEST_DIR); go mod tidy -.PHONY: generate-manifests-kcp -generate-manifests-kcp: $(CONTROLLER_GEN) - $(CONTROLLER_GEN) \ - paths=./controlplane/kubeadm/api/... \ - paths=./controlplane/kubeadm/controllers/... \ - paths=./controlplane/kubeadm/internal/webhooks/... \ - crd:crdVersions=v1 \ - rbac:roleName=manager-role \ - output:crd:dir=./controlplane/kubeadm/config/crd/bases \ - output:rbac:dir=./controlplane/kubeadm/config/rbac \ - output:webhook:dir=./controlplane/kubeadm/config/webhook \ - webhook +.PHONY: lint +lint: $(GOLANGCI_LINT) ## Lint the codebase + $(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS) + cd $(TEST_DIR); $(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS) + cd $(TOOLS_DIR); $(GOLANGCI_LINT) run -v $(GOLANGCI_LINT_EXTRA_ARGS) + +.PHONY: lint-fix +lint-fix: $(GOLANGCI_LINT) ## Lint the codebase and run auto-fixers if supported by the linter + GOLANGCI_LINT_EXTRA_ARGS=--fix $(MAKE) lint + +apidiff: $(GO_APIDIFF) ## Check for API differences + $(GO_APIDIFF) $(shell git rev-parse origin/main) --print-compatible + +.PHONY: format-tiltfile +format-tiltfile: ## Format the Tiltfile + ./hack/verify-starlark.sh fix + +.PHONY: verify +verify: ## Run all verify-* targets + ./hack/verify-doctoc.sh + $(MAKE) verify-boilerplate + $(MAKE) verify-shellcheck + $(MAKE) verify-tiltfile + $(MAKE) verify-modules + $(MAKE) verify-gen + $(MAKE) verify-conversions + $(MAKE) verify-docker-provider + +.PHONY: verify-modules +verify-modules: modules ## Verify go modules are up to date + @if !(git diff --quiet HEAD -- go.sum go.mod $(TOOLS_DIR)/go.mod $(TOOLS_DIR)/go.sum $(TEST_DIR)/go.mod $(TEST_DIR)/go.sum); then \ + git diff; \ + echo "go module files are out of date"; exit 1; \ + fi + @if (find . -name 'go.mod' | xargs -n1 grep -q -i 'k8s.io/client-go.*+incompatible'); then \ + find . -name "go.mod" -exec grep -i 'k8s.io/client-go.*+incompatible' {} \; -print; \ + echo "go module contains an incompatible client-go version"; exit 1; \ + fi + +.PHONY: verify-gen +verify-gen: generate ## Verfiy go generated files are up to date + @if !(git diff --quiet HEAD); then \ + git diff; \ + echo "generated files are out of date, run make generate"; exit 1; \ + fi + +.PHONY: verify-conversions +verify-conversions: $(CONVERSION_VERIFIER) ## Verifies API expected conversion are in place + $(CONVERSION_VERIFIER) + +.PHONY: verify-boilerplate +verify-boilerplate: ## Verify boilerplate text exists in each file + ./hack/verify-boilerplate.sh + +.PHONY: verify-shellcheck +verify-shellcheck: ## Verify shell files + ./hack/verify-shellcheck.sh + +.PHONY: verify-tiltfile +verify-tiltfile: ## Verify Tiltfile format + ./hack/verify-starlark.sh -## -------------------------------------- -## Modules -## -------------------------------------- +.PHONY: verify-docker-provider +verify-docker-provider: + @echo "Verifying CAPD" + cd $(CAPD_DIR); $(MAKE) verify -.PHONY: modules -modules: ## Runs go mod to ensure modules are up to date. - go mod tidy - cd $(TOOLS_DIR); go mod tidy - cd $(TEST_DIR); go mod tidy +.PHONY: verify-book-links +verify-book-links: + $(MAKE) -C docs/book verify ## -------------------------------------- -## Docker +## Binaries ## -------------------------------------- -.PHONY: docker-pull-prerequisites -docker-pull-prerequisites: - docker pull docker.io/docker/dockerfile:1.1-experimental - docker pull $(GO_CONTAINER_IMAGE) - docker pull gcr.io/distroless/static:latest +##@ build: + +.PHONY: clusterctl +clusterctl: ## Build the clusterctl binary + go build -trimpath -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/clusterctl sigs.k8s.io/cluster-api/cmd/clusterctl + +.PHONY: managers +managers: ## Run all manager-* targets + $(MAKE) manager-core + $(MAKE) manager-kubeadm-bootstrap + $(MAKE) manager-kubeadm-control-plane + +.PHONY: manager-core +manager-core: ## Build the core manager binary into the ./bin folder + go build -trimpath -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/manager sigs.k8s.io/cluster-api + +.PHONY: manager-kubeadm-bootstrap +manager-kubeadm-bootstrap: ## Build the kubeadm bootstrap manager binary into the ./bin folder + go build -trimpath -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/kubeadm-bootstrap-manager sigs.k8s.io/cluster-api/bootstrap/kubeadm + +.PHONY: manager-kubeadm-control-plane +manager-kubeadm-control-plane: ## Build the kubeadm control plane manager binary into the ./bin folder + go build -trimpath -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/kubeadm-control-plane-manager sigs.k8s.io/cluster-api/controlplane/kubeadm .PHONY: docker-build -docker-build: docker-pull-prerequisites ## Build the docker images for controller managers +docker-build: docker-pull-prerequisites ## Run docker-build-core and all docker-build-kubeadm-* targets $(MAKE) ARCH=$(ARCH) docker-build-core $(MAKE) ARCH=$(ARCH) docker-build-kubeadm-bootstrap $(MAKE) ARCH=$(ARCH) docker-build-kubeadm-control-plane +.PHONY: docker-build-all +docker-build-all: $(addprefix docker-build-,$(ALL_ARCH)) ## Build all the architecture docker images + +docker-build-%: + $(MAKE) ARCH=$* docker-build + .PHONY: docker-build-core docker-build-core: ## Build the docker image for core controller manager DOCKER_BUILDKIT=1 docker build --build-arg builder_image=$(GO_CONTAINER_IMAGE) --build-arg goproxy=$(GOPROXY) --build-arg ARCH=$(ARCH) --build-arg ldflags="$(LDFLAGS)" . -t $(CONTROLLER_IMG)-$(ARCH):$(TAG) @@ -456,72 +425,98 @@ docker-build-kubeadm-control-plane: ## Build the docker image for kubeadm contro $(MAKE) set-manifest-image MANIFEST_IMG=$(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG)-$(ARCH) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./controlplane/kubeadm/config/default/manager_image_patch.yaml" $(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./controlplane/kubeadm/config/default/manager_pull_policy.yaml" -.PHONY: docker-push -docker-push: ## Push the docker images - docker push $(CONTROLLER_IMG)-$(ARCH):$(TAG) - docker push $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG)-$(ARCH):$(TAG) - docker push $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG)-$(ARCH):$(TAG) +.PHONY: e2e-framework +e2e-framework: ## Builds the CAPI e2e framework + cd $(E2E_FRAMEWORK_DIR); go build ./... + +$(SETUP_ENVTEST): $(TOOLS_DIR)/go.mod # Build setup-envtest from tools folder. + cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/setup-envtest sigs.k8s.io/controller-runtime/tools/setup-envtest + +$(CONTROLLER_GEN): $(TOOLS_DIR)/go.mod # Build controller-gen from tools folder. + cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen + +$(GOTESTSUM): $(TOOLS_DIR)/go.mod # Build gotestsum from tools folder. + cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/gotestsum gotest.tools/gotestsum + +$(CONVERSION_GEN): $(TOOLS_DIR)/go.mod # Build conversion-gen from tools folder. + cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/conversion-gen k8s.io/code-generator/cmd/conversion-gen + +$(CONVERSION_VERIFIER): $(TOOLS_DIR)/go.mod # Build conversion-verifier from tools folder. + cd $(TOOLS_DIR); go build -tags=tools -o $(BIN_DIR)/conversion-verifier sigs.k8s.io/cluster-api/hack/tools/conversion-verifier + +$(GO_APIDIFF): $(TOOLS_DIR)/go.mod # Build go-apidiff from tools folder. + cd $(TOOLS_DIR) && go build -tags=tools -o $(GO_APIDIFF_BIN) github.com/joelanford/go-apidiff + +$(ENVSUBST): $(TOOLS_DIR)/go.mod # Build envsubst from tools folder. + cd $(TOOLS_DIR) && go build -tags=tools -o $(ENVSUBST_BIN) github.com/drone/envsubst/v2/cmd/envsubst + +$(YQ): $(TOOLS_DIR)/go.mod # Build yq from tools folder. + cd $(TOOLS_DIR) && go build -tags=tools -o $(YQ_BIN) github.com/mikefarah/yq/v4 + +$(KPROMO): $(TOOLS_DIR)/go.mod # Build kpromo from tools folder. + cd $(TOOLS_DIR) && go build -tags=tools -o $(KPROMO_BIN) sigs.k8s.io/promo-tools/v3/cmd/kpromo + +$(KUSTOMIZE): # Download kustomize using hack script into tools folder. + hack/ensure-kustomize.sh + +$(GOLANGCI_LINT): .github/workflows/golangci-lint.yml # Download golanci-lint using hack script into tools folder. + hack/ensure-golangci-lint.sh \ + -b $(TOOLS_DIR)/$(BIN_DIR) \ + $(shell cat .github/workflows/golangci-lint.yml | grep version | sed 's/.*version: //') ## -------------------------------------- -## Docker — All ARCH +## Testing ## -------------------------------------- -.PHONY: docker-build-all ## Build all the architecture docker images -docker-build-all: $(addprefix docker-build-,$(ALL_ARCH)) +##@ test: -docker-build-%: - $(MAKE) ARCH=$* docker-build +ARTIFACTS ?= ${ROOT_DIR}/_artifacts -.PHONY: docker-push-all ## Push all the architecture docker images -docker-push-all: $(addprefix docker-push-,$(ALL_ARCH)) - $(MAKE) docker-push-core-manifest - $(MAKE) docker-push-kubeadm-bootstrap-manifest - $(MAKE) docker-push-kubeadm-control-plane-manifest +KUBEBUILDER_ASSETS ?= $(shell $(SETUP_ENVTEST) use --use-env -p path $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION)) -docker-push-%: - $(MAKE) ARCH=$* docker-push +.PHONY: test +test: $(SETUP_ENVTEST) ## Run all the tests + KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test ./... $(TEST_ARGS) -.PHONY: docker-push-core-manifest -docker-push-core-manifest: ## Push the fat manifest docker image for the core image. - ## Minimum docker version 18.06.0 is required for creating and pushing manifest images. - docker manifest create --amend $(CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(CONTROLLER_IMG)\-&:$(TAG)~g") - @for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${CONTROLLER_IMG}:${TAG} ${CONTROLLER_IMG}-$${arch}:${TAG}; done - docker manifest push --purge $(CONTROLLER_IMG):$(TAG) - $(MAKE) set-manifest-image MANIFEST_IMG=$(CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./config/default/manager_image_patch.yaml" - $(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./config/default/manager_pull_policy.yaml" +.PHONY: test-e2e +test-e2e: ## Run the e2e tests + $(MAKE) -C $(TEST_DIR)/e2e run -.PHONY: docker-push-kubeadm-bootstrap-manifest -docker-push-kubeadm-bootstrap-manifest: ## Push the fat manifest docker image for the kubeadm bootstrap image. - ## Minimum docker version 18.06.0 is required for creating and pushing manifest images. - docker manifest create --amend $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(KUBEADM_BOOTSTRAP_CONTROLLER_IMG)\-&:$(TAG)~g") - @for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${KUBEADM_BOOTSTRAP_CONTROLLER_IMG}:${TAG} ${KUBEADM_BOOTSTRAP_CONTROLLER_IMG}-$${arch}:${TAG}; done - docker manifest push --purge $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG):$(TAG) - $(MAKE) set-manifest-image MANIFEST_IMG=$(KUBEADM_BOOTSTRAP_CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./bootstrap/kubeadm/config/default/manager_image_patch.yaml" - $(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./bootstrap/kubeadm/config/default/manager_pull_policy.yaml" +.PHONY: test-junit +test-junit: $(SETUP_ENVTEST) $(GOTESTSUM) ## Run tests with verbose setting and generate a junit report + set +o errexit; (KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test -json ./... $(TEST_ARGS); echo $$? > $(ARTIFACTS)/junit.exitcode) | tee $(ARTIFACTS)/junit.stdout + $(GOTESTSUM) --junitfile $(ARTIFACTS)/junit.xml --raw-command cat $(ARTIFACTS)/junit.stdout + exit $$(cat $(ARTIFACTS)/junit.exitcode) -.PHONY: docker-push-kubeadm-control-plane-manifest -docker-push-kubeadm-control-plane-manifest: ## Push the fat manifest docker image for the kubeadm control plane image. - ## Minimum docker version 18.06.0 is required for creating and pushing manifest images. - docker manifest create --amend $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG)\-&:$(TAG)~g") - @for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${KUBEADM_CONTROL_PLANE_CONTROLLER_IMG}:${TAG} ${KUBEADM_CONTROL_PLANE_CONTROLLER_IMG}-$${arch}:${TAG}; done - docker manifest push --purge $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG):$(TAG) - $(MAKE) set-manifest-image MANIFEST_IMG=$(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./controlplane/kubeadm/config/default/manager_image_patch.yaml" - $(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./controlplane/kubeadm/config/default/manager_pull_policy.yaml" +.PHONY: test-cover +test-cover: ## Run tests with code coverage and code generate reports + $(MAKE) test TEST_ARGS="$(TEST_ARGS) -coverprofile=out/coverage.out" + go tool cover -func=out/coverage.out -o out/coverage.txt + go tool cover -html=out/coverage.out -o out/coverage.html -.PHONY: set-manifest-pull-policy -set-manifest-pull-policy: - $(info Updating kustomize pull policy file for manager resources) - sed -i'' -e 's@imagePullPolicy: .*@imagePullPolicy: '"$(PULL_POLICY)"'@' $(TARGET_RESOURCE) +.PHONY: test-verbose +test-verbose: ## Run tests with verbose settings + $(MAKE) test TEST_ARGS="$(TEST_ARGS) -v" -.PHONY: set-manifest-image -set-manifest-image: - $(info Updating kustomize image patch file for manager resource) - sed -i'' -e 's@image: .*@image: '"${MANIFEST_IMG}:$(MANIFEST_TAG)"'@' $(TARGET_RESOURCE) +.PHONY: serve-book +serve-book: ## Build and serve the book with live-reloading enabled + $(MAKE) -C docs/book serve + +.PHONY: kind-cluster +kind-cluster: ## Create a new kind cluster designed for testing with Tilt + hack/kind-install-for-capd.sh + +.PHONY: docker-build-e2e +docker-build-e2e: ## Rebuild all Cluster API provider images to be used in the e2e tests + make docker-build REGISTRY=gcr.io/k8s-staging-cluster-api PULL_POLICY=IfNotPresent + $(MAKE) -C $(CAPD_DIR) docker-build REGISTRY=gcr.io/k8s-staging-cluster-api PULL_POLICY=IfNotPresent ## -------------------------------------- ## Release ## -------------------------------------- +##@ release: + ## latest git tag for the commit, e.g., v0.3.10 RELEASE_TAG ?= $(shell git describe --abbrev=0 2>/dev/null) # the previous release tag, e.g., v0.3.9, excluding pre-release tags @@ -540,7 +535,7 @@ $(RELEASE_NOTES_DIR): mkdir -p $(RELEASE_NOTES_DIR)/ .PHONY: release -release: clean-release ## Builds and push container images using the latest git tag for the commit. +release: clean-release ## Build and push container images using the latest git tag for the commit @if [ -z "${RELEASE_TAG}" ]; then echo "RELEASE_TAG is not set"; exit 1; fi @if ! [ -z "$$(git status --porcelain)" ]; then echo "Your local git repository contains uncommitted changes, use git clean before proceeding."; exit 1; fi git checkout "${RELEASE_TAG}" @@ -569,7 +564,7 @@ manifest-modification: # Set the manifest images to the staging/production bucke $(MAKE) set-manifest-pull-policy PULL_POLICY=IfNotPresent TARGET_RESOURCE="./controlplane/kubeadm/config/default/manager_pull_policy.yaml" .PHONY: release-manifests -release-manifests: $(RELEASE_DIR) $(KUSTOMIZE) ## Builds the manifests to publish with a release +release-manifests: $(RELEASE_DIR) $(KUSTOMIZE) ## Build the manifests to publish with a release # Build core-components. $(KUSTOMIZE) build config/default > $(RELEASE_DIR)/core-components.yaml # Build bootstrap-components. @@ -587,14 +582,14 @@ release-manifests: $(RELEASE_DIR) $(KUSTOMIZE) ## Builds the manifests to publis cp metadata.yaml $(RELEASE_DIR)/metadata.yaml .PHONY: release-manifests-dev -release-manifests-dev: ## Builds the development manifests and copies them in the release folder +release-manifests-dev: ## Build the development manifests and copies them in the release folder # Release CAPD components and add them to the release dir $(MAKE) -C $(CAPD_DIR) release cp $(CAPD_DIR)/out/infrastructure-components.yaml $(RELEASE_DIR)/infrastructure-components-development.yaml # Adds CAPD templates cp $(CAPD_DIR)/templates/* $(RELEASE_DIR)/ -release-binaries: ## Builds the binaries to publish with a release +release-binaries: ## Build the binaries to publish with a release RELEASE_BINARY=clusterctl-linux-amd64 BUILD_PATH=./cmd/clusterctl GOOS=linux GOARCH=amd64 $(MAKE) release-binary RELEASE_BINARY=clusterctl-linux-arm64 BUILD_PATH=./cmd/clusterctl GOOS=linux GOARCH=arm64 $(MAKE) release-binary RELEASE_BINARY=clusterctl-darwin-amd64 BUILD_PATH=./cmd/clusterctl GOOS=darwin GOARCH=amd64 $(MAKE) release-binary @@ -614,11 +609,11 @@ release-binary: $(RELEASE_DIR) -o $(RELEASE_DIR)/$(notdir $(RELEASE_BINARY)) $(BUILD_PATH) .PHONY: release-staging -release-staging: ## Builds and push container images to the staging bucket. +release-staging: ## Build and push container images to the staging bucket REGISTRY=$(STAGING_REGISTRY) $(MAKE) docker-build-all docker-push-all release-alias-tag .PHONY: release-staging-nightly -release-staging-nightly: ## Tags and push container images to the staging bucket. Example image tag: cluster-api-controller:nightly_main_20210121 +release-staging-nightly: ## Tag and push container images to the staging bucket. Example image tag: cluster-api-controller:nightly_main_20210121 $(eval NEW_RELEASE_ALIAS_TAG := nightly_$(RELEASE_ALIAS_TAG)_$(shell date +'%Y%m%d')) echo $(NEW_RELEASE_ALIAS_TAG) $(MAKE) release-alias-tag TAG=$(RELEASE_ALIAS_TAG) RELEASE_ALIAS_TAG=$(NEW_RELEASE_ALIAS_TAG) @@ -630,7 +625,7 @@ release-staging-nightly: ## Tags and push container images to the staging bucket gsutil cp $(RELEASE_DIR)/* gs://$(STAGING_BUCKET)/components/$(NEW_RELEASE_ALIAS_TAG) .PHONY: release-alias-tag -release-alias-tag: ## Adds the tag to the last build tag. +release-alias-tag: ## Add the tag to the last build tag gcloud container images add-tag $(CONTROLLER_IMG):$(TAG) $(CONTROLLER_IMG):$(RELEASE_ALIAS_TAG) gcloud container images add-tag $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG):$(TAG) $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG):$(RELEASE_ALIAS_TAG) gcloud container images add-tag $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG):$(TAG) $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG):$(RELEASE_ALIAS_TAG) @@ -643,10 +638,74 @@ release-notes: $(RELEASE_NOTES_DIR) $(RELEASE_NOTES) promote-images: $(KPROMO) $(KPROMO) pr --project cluster-api --tag $(RELEASE_TAG) --reviewers "$(IMAGE_REVIEWERS)" --fork $(USER_FORK) +## -------------------------------------- +## Docker +## -------------------------------------- + +.PHONY: docker-pull-prerequisites +docker-pull-prerequisites: + docker pull docker.io/docker/dockerfile:1.1-experimental + docker pull $(GO_CONTAINER_IMAGE) + docker pull gcr.io/distroless/static:latest + +.PHONY: docker-push +docker-push: ## Push the docker images + docker push $(CONTROLLER_IMG)-$(ARCH):$(TAG) + docker push $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG)-$(ARCH):$(TAG) + docker push $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG)-$(ARCH):$(TAG) + +.PHONY: docker-push-all +docker-push-all: $(addprefix docker-push-,$(ALL_ARCH)) ## Push all the architecture docker images + $(MAKE) docker-push-manifest-core + $(MAKE) docker-push-manifest-kubeadm-bootstrap + $(MAKE) docker-push-manifest-kubeadm-control-plane + +docker-push-%: + $(MAKE) ARCH=$* docker-push + +.PHONY: docker-push-manifest-core +docker-push-manifest-core: ## Push the multiarch manifest for the core docker images + ## Minimum docker version 18.06.0 is required for creating and pushing manifest images. + docker manifest create --amend $(CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(CONTROLLER_IMG)\-&:$(TAG)~g") + @for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${CONTROLLER_IMG}:${TAG} ${CONTROLLER_IMG}-$${arch}:${TAG}; done + docker manifest push --purge $(CONTROLLER_IMG):$(TAG) + $(MAKE) set-manifest-image MANIFEST_IMG=$(CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./config/default/manager_image_patch.yaml" + $(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./config/default/manager_pull_policy.yaml" + +.PHONY: docker-push-manifest-kubeadm-bootstrap +docker-push-manifest-kubeadm-bootstrap: ## Push the multiarch manifest for the the kubeadm bootstrap docker images + ## Minimum docker version 18.06.0 is required for creating and pushing manifest images. + docker manifest create --amend $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(KUBEADM_BOOTSTRAP_CONTROLLER_IMG)\-&:$(TAG)~g") + @for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${KUBEADM_BOOTSTRAP_CONTROLLER_IMG}:${TAG} ${KUBEADM_BOOTSTRAP_CONTROLLER_IMG}-$${arch}:${TAG}; done + docker manifest push --purge $(KUBEADM_BOOTSTRAP_CONTROLLER_IMG):$(TAG) + $(MAKE) set-manifest-image MANIFEST_IMG=$(KUBEADM_BOOTSTRAP_CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./bootstrap/kubeadm/config/default/manager_image_patch.yaml" + $(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./bootstrap/kubeadm/config/default/manager_pull_policy.yaml" + +.PHONY: docker-push-manifest-kubeadm-control-plane +docker-push-manifest-kubeadm-control-plane: ## Push the multiarch manifest for the the kubeadm control plane docker images + ## Minimum docker version 18.06.0 is required for creating and pushing manifest images. + docker manifest create --amend $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG)\-&:$(TAG)~g") + @for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${KUBEADM_CONTROL_PLANE_CONTROLLER_IMG}:${TAG} ${KUBEADM_CONTROL_PLANE_CONTROLLER_IMG}-$${arch}:${TAG}; done + docker manifest push --purge $(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG):$(TAG) + $(MAKE) set-manifest-image MANIFEST_IMG=$(KUBEADM_CONTROL_PLANE_CONTROLLER_IMG) MANIFEST_TAG=$(TAG) TARGET_RESOURCE="./controlplane/kubeadm/config/default/manager_image_patch.yaml" + $(MAKE) set-manifest-pull-policy TARGET_RESOURCE="./controlplane/kubeadm/config/default/manager_pull_policy.yaml" + +.PHONY: set-manifest-pull-policy +set-manifest-pull-policy: + $(info Updating kustomize pull policy file for manager resources) + sed -i'' -e 's@imagePullPolicy: .*@imagePullPolicy: '"$(PULL_POLICY)"'@' $(TARGET_RESOURCE) + +.PHONY: set-manifest-image +set-manifest-image: + $(info Updating kustomize image patch file for manager resource) + sed -i'' -e 's@image: .*@image: '"${MANIFEST_IMG}:$(MANIFEST_TAG)"'@' $(TARGET_RESOURCE) + ## -------------------------------------- ## Cleanup / Verification ## -------------------------------------- +##@ clean: + .PHONY: clean clean: ## Remove all generated files $(MAKE) clean-bin @@ -657,81 +716,41 @@ clean-bin: ## Remove all generated binaries rm -rf $(BIN_DIR) rm -rf $(TOOLS_BIN_DIR) -.PHONY: clean-release -clean-release: ## Remove the release folder - rm -rf $(RELEASE_DIR) - -.PHONY: clean-release-git -clean-release-git: ## Restores the git files usually modified during a release - git restore ./*manager_image_patch.yaml ./*manager_pull_policy.yaml - .PHONY: clean-book clean-book: ## Remove all generated GitBook files rm -rf ./docs/book/_book +.PHONY: clean-release +clean-release: ## Remove the release folder + rm -rf $(RELEASE_DIR) + .PHONY: clean-manifests ## Reset manifests in config directories back to main clean-manifests: @read -p "WARNING: This will reset all config directories to local main. Press [ENTER] to continue." git checkout main config bootstrap/kubeadm/config controlplane/kubeadm/config $(CAPD_DIR)/config -.PHONY: format-tiltfile -format-tiltfile: ## Format Tiltfile - ./hack/verify-starlark.sh fix - -.PHONY: verify -verify: - ./hack/verify-boilerplate.sh - ./hack/verify-doctoc.sh - ./hack/verify-shellcheck.sh - ./hack/verify-starlark.sh - $(MAKE) verify-modules - $(MAKE) verify-gen - $(MAKE) verify-conversions - $(MAKE) verify-docker-provider - -.PHONY: verify-modules -verify-modules: modules - @if !(git diff --quiet HEAD -- go.sum go.mod $(TOOLS_DIR)/go.mod $(TOOLS_DIR)/go.sum $(TEST_DIR)/go.mod $(TEST_DIR)/go.sum); then \ - git diff; \ - echo "go module files are out of date"; exit 1; \ - fi - @if (find . -name 'go.mod' | xargs -n1 grep -q -i 'k8s.io/client-go.*+incompatible'); then \ - find . -name "go.mod" -exec grep -i 'k8s.io/client-go.*+incompatible' {} \; -print; \ - echo "go module contains an incompatible client-go version"; exit 1; \ - fi - -.PHONY: verify-gen -verify-gen: generate - @if !(git diff --quiet HEAD); then \ - git diff; \ - echo "generated files are out of date, run make generate"; exit 1; \ - fi - -.PHONY: verify-conversions -verify-conversions: $(CONVERSION_VERIFIER) - $(CONVERSION_VERIFIER) - -.PHONY: verify-docker-provider -verify-docker-provider: - @echo "Verifying CAPD" - cd $(CAPD_DIR); $(MAKE) verify +.PHONY: clean-release-git +clean-release-git: ## Restores the git files usually modified during a release + git restore ./*manager_image_patch.yaml ./*manager_pull_policy.yaml -.PHONY: verify-book-links -verify-book-links: - $(MAKE) -C docs/book verify +.PHONY: clean-generated-conversions +clean-generated-conversions: ## Remove files generated by conversion-gen from the mentioned dirs. Example SRC_DIRS="./api/v1alpha4" + (IFS=','; for i in $(SRC_DIRS); do find $$i -type f -name 'zz_generated.conversion*' -exec rm -f {} \;; done) ## -------------------------------------- -## Others / Utilities +## Hack / Tools ## -------------------------------------- -.PHONY: diagrams -diagrams: ## Build proposal diagrams - $(MAKE) -C docs diagrams - -.PHONY: serve-book -serve-book: ## Build and serve the book with live-reloading enabled - $(MAKE) -C docs/book serve - -.PHONY: clean-generated-conversions -clean-generated-conversions: ## Remove files generated by conversion-gen from the mentioned dirs - (IFS=','; for i in $(SRC_DIRS); do find $$i -type f -name 'zz_generated.conversion*' -exec rm -f {} \;; done) +##@ hack/tools: + +controller-gen: $(CONTROLLER_GEN) ## Build a local copy of controller-gen +conversion-gen: $(CONVERSION_GEN) ## Build a local copy of conversion-gen +conversion-verifier: $(CONVERSION_VERIFIER) ## Build a local copy of conversion-verifier +gotestsum: $(GOTESTSUM) ## Build a local copy of gotestsum +go-apidiff: $(GO_APIDIFF) ## Build a local copy of apidiff +golangci-lint: $(GOLANGCI_LINT) ## Build a local copy of golangci-lint +envsubst: $(ENVSUBST) ## Build a local copy of envsubst +kustomize: $(KUSTOMIZE) ## Build a local copy of kustomize +setup-envtest: $(SETUP_ENVTEST) ## Build a local copy of setup-envtest +yq: $(YQ) ## Build a local copy of yq +kpromo: $(KPROMO) ## Build a local copy of kpromo