-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathMakefile
More file actions
121 lines (89 loc) · 3.93 KB
/
Makefile
File metadata and controls
121 lines (89 loc) · 3.93 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
IMG ?= controller:latest
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.33.2
ENVTEST = go run -mod=vendor ${PROJECT_DIR}/vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest
GOLANGCI_LINT = go run -mod=vendor ${PROJECT_DIR}/vendor/github.com/golangci/golangci-lint/v2/cmd/golangci-lint
HOME ?= /tmp/kubebuilder-testing
ifeq ($(HOME), /)
HOME = /tmp/kubebuilder-testing
endif
.PHONY: help all verify test build operator migration manifests-gen ocp-manifests unit e2e run fmt vet lint vendor image push aws-cluster azure-cluster gcp-cluster powervs-cluster vsphere-cluster
.DEFAULT_GOAL := build
help: ## Display this help message
@echo "Available targets:"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
all: build ## Build all binaries
verify-%:
make $*
./hack/verify-diff.sh
verify: fmt lint verify-ocp-manifests ## Run formatting and linting checks
test: verify unit ## Run verification and unit tests
build: bin/capi-operator bin/capi-controllers bin/machine-api-migration bin/crd-compatibility-checker manifests-gen ## Build all binaries
clean:
rm -rf bin/*
# Ensure bin directory exists for build outputs
bin/:
mkdir -p bin
.PHONY: manifests-gen
manifests-gen: | bin/ ## Build manifests-gen binary
cd manifests-gen && go build -o ../bin/manifests-gen && cd ..
ocp-manifests: manifests-gen ## Generate admission policy profiles for image embedding
./bin/manifests-gen \
--manifests-path ./capi-operator-manifests \
--profile-name default \
--kustomize-dir ./admission-policies/default \
--name cluster-capi-operator \
--install-order 30
./bin/manifests-gen \
--manifests-path ./capi-operator-manifests \
--profile-name aws \
--kustomize-dir ./admission-policies/aws \
--name cluster-capi-operator \
--platform AWS \
--install-order 30
bin/%: FORCE | bin/
go build -o "$@" "./cmd/$*"
.PHONY: localtestenv
localtestenv: .localtestenv
.localtestenv: Makefile ## Set up local test environment
KUBEBUILDER_ASSETS="$$($(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path --bin-dir $(PROJECT_DIR)/bin --index https://raw.githubusercontent.com/openshift/api/master/envtest-releases.yaml)"; \
echo "KUBEBUILDER_ASSETS=$${KUBEBUILDER_ASSETS}" > $@
TEST_DIRS ?= ./pkg/... ./manifests-gen/...
unit: .localtestenv ## Run unit tests
./hack/test.sh "$(TEST_DIRS)" 20m
.PHONY: e2e
e2e: ## Run e2e tests against active kubeconfig
./hack/test.sh "./e2e/..." 120m
run: ## Run the operator against the configured Kubernetes cluster
oc -n openshift-cluster-api patch lease cluster-capi-operator-leader -p '{"spec":{"acquireTime": null, "holderIdentity": null, "renewTime": null}}' --type=merge
go run cmd/cluster-capi-operator/main.go --images-json=./dev-images.json --leader-elect=true --leader-elect-lease-duration=120s --namespace="openshift-cluster-api" --leader-elect-resource-namespace="openshift-cluster-api"
fmt: ## Format Go code
$(call ensure-home, ${GOLANGCI_LINT} run ./... --fix)
lint: ## Run linter checks
$(call ensure-home, ${GOLANGCI_LINT} run ./...)
vendor: ## Vendor dependencies
./hack/vendor.sh
image: ## Build the Docker image
docker build -t ${IMG} .
push: ## Push the Docker image
docker push ${IMG}
aws-cluster: ## Create an AWS cluster for testing
./hack/clusters/create-aws.sh
azure-cluster: ## Create an Azure cluster for testing
./hack/clusters/create-azure.sh
gcp-cluster: ## Create a GCP cluster for testing
./hack/clusters/create-gcp.sh
powervs-cluster: ## Create a PowerVS cluster for testing
./hack/clusters/create-powervs.sh
vsphere-cluster: ## Create a vSphere cluster for testing
./hack/clusters/create-vsphere.sh
define ensure-home
@ export HOME=$${HOME:=/tmp/kubebuilder-testing}; \
if [ $${HOME} == "/" ]; then \
export HOME=/tmp/kubebuilder-testing; \
fi; \
$(1)
endef
.PHONY: FORCE
FORCE: