-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathMakefile
103 lines (77 loc) · 2.54 KB
/
Makefile
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
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.31.1
ENVTEST = go run ${PROJECT_DIR}/vendor/sigs.k8s.io/controller-runtime/tools/setup-envtest
GOLANGCI_LINT = go run ${PROJECT_DIR}/vendor/github.com/golangci/golangci-lint/cmd/golangci-lint
HOME ?= /tmp/kubebuilder-testing
ifeq ($(HOME), /)
HOME = /tmp/kubebuilder-testing
endif
all: build
verify-%:
make $*
./hack/verify-diff.sh
verify: fmt lint
# Run tests
test: verify unit
# Build binaries
build: operator migration manifests-gen
.PHONY: manifests-gen
manifests-gen:
# building manifests-gen
cd manifests-gen && go build -o ../bin/manifests-gen && cd ..
operator:
# building cluster-capi-operator
go build -o bin/cluster-capi-operator cmd/cluster-capi-operator/main.go
migration:
# building migration
go build -o bin/machine-api-migration cmd/machine-api-migration/main.go
unit:
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path --bin-dir $(PROJECT_DIR)/bin --index https://raw.githubusercontent.com/openshift/api/master/envtest-releases.yaml)" ./hack/test.sh "./pkg/... ./manifests-gen/..." 5m
.PHONY: e2e
e2e:
./hack/test.sh "./e2e/..." 30m
# Run against the configured Kubernetes cluster in ~/.kube/config
run:
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"
# Run go fmt against code
.PHONY: fmt
fmt:
$(call ensure-home, ${GOLANGCI_LINT} run ./... --fix)
# Run go vet against code
.PHONY: vet
vet: lint
.PHONY: lint
lint:
$(call ensure-home, ${GOLANGCI_LINT} run ./...)
# Run go mod
.PHONY: vendor
vendor:
./hack/vendor.sh
# Build the docker image
.PHONY: image
image:
docker build -t ${IMG} .
# Push the docker image
.PHONY: push
push:
docker push ${IMG}
aws-cluster:
./hack/clusters/create-aws.sh
azure-cluster:
./hack/clusters/create-azure.sh
gcp-cluster:
./hack/clusters/create-gcp.sh
powervs-cluster:
./hack/clusters/create-powervs.sh
vsphere-cluster:
./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