|
1 |
| - |
| 1 | +########################### |
| 2 | +# Configuration Variables # |
| 3 | +########################### |
2 | 4 | # Image URL to use all building/pushing image targets
|
3 |
| -IMG ?= controller:latest |
| 5 | +export IMAGE_REPO ?= quay.io/operator-framework/operator-controller |
| 6 | +export IMAGE_TAG ?= devel |
| 7 | +export GO_BUILD_TAGS ?= upstream |
| 8 | +IMG?=$(IMAGE_REPO):$(IMAGE_TAG) |
| 9 | + |
| 10 | +OPERATOR_CONTROLLER_NAMESPACE ?= operator-controller-system |
| 11 | +KIND_CLUSTER_NAME ?= operator-controller |
| 12 | + |
4 | 13 | # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
|
5 | 14 | ENVTEST_K8S_VERSION = 1.25.0
|
6 | 15 |
|
|
16 | 25 | SHELL = /usr/bin/env bash -o pipefail
|
17 | 26 | .SHELLFLAGS = -ec
|
18 | 27 |
|
| 28 | +# Disable -j flag for make |
| 29 | +.NOTPARALLEL: |
| 30 | + |
19 | 31 | .PHONY: all
|
20 | 32 | all: build
|
21 | 33 |
|
@@ -54,25 +66,46 @@ fmt: ## Run go fmt against code.
|
54 | 66 | vet: ## Run go vet against code.
|
55 | 67 | go vet ./...
|
56 | 68 |
|
57 |
| -.PHONY: test |
58 |
| -test: manifests generate fmt vet envtest ## Run tests. |
| 69 | +.PHONY: test test-e2e e2e kind-load kind-cluster kind-cluster-cleanup |
| 70 | +test: manifests generate fmt vet envtest test-e2e ## Run all tests. |
59 | 71 | KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out
|
60 | 72 |
|
| 73 | +FOCUS := $(if $(TEST),-v -focus "$(TEST)") |
| 74 | +E2E_FLAGS ?= "" |
| 75 | +test-e2e: ginkgo ## Run the e2e tests |
| 76 | + $(GINKGO) --tags $(GO_BUILD_TAGS) $(E2E_FLAGS) -trace -progress $(FOCUS) test/e2e |
| 77 | + |
| 78 | +e2e: KIND_CLUSTER_NAME=operator-controller-e2e |
| 79 | +e2e: run test-e2e kind-cluster-cleanup ## Run e2e test suite on local kind cluster |
| 80 | + |
| 81 | +kind-load: kind ## Loads the currently constructed image onto the cluster |
| 82 | + $(KIND) load docker-image $(IMG) --name $(KIND_CLUSTER_NAME) |
| 83 | + |
| 84 | +kind-cluster: kind kind-cluster-cleanup ## Standup a kind cluster |
| 85 | + $(KIND) create cluster --name ${KIND_CLUSTER_NAME} |
| 86 | + $(KIND) export kubeconfig --name ${KIND_CLUSTER_NAME} |
| 87 | + |
| 88 | +kind-cluster-cleanup: kind ## Delete the kind cluster |
| 89 | + $(KIND) delete cluster --name ${KIND_CLUSTER_NAME} |
| 90 | + |
61 | 91 | ##@ Build
|
62 | 92 |
|
63 | 93 | .PHONY: build
|
64 | 94 | build: manifests generate fmt vet ## Build manager binary.
|
65 | 95 | go build -o bin/manager main.go
|
66 | 96 |
|
67 | 97 | .PHONY: run
|
68 |
| -run: manifests generate fmt vet ## Run a controller from your host. |
69 |
| - go run ./main.go |
| 98 | +run: docker-build kind-cluster kind-load install deploy wait ## Build the operator-controller then deploy it into a new kind cluster. |
| 99 | + |
| 100 | +.PHONY: wait |
| 101 | +wait: |
| 102 | + kubectl wait --for=condition=Available --namespace=$(OPERATOR_CONTROLLER_NAMESPACE) deployment/operator-controller-controller-manager --timeout=60s |
70 | 103 |
|
71 | 104 | # If you wish built the manager image targeting other platforms you can use the --platform flag.
|
72 | 105 | # (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
|
73 | 106 | # More info: https://docs.docker.com/develop/develop-images/build_enhancements/
|
74 | 107 | .PHONY: docker-build
|
75 |
| -docker-build: test ## Build docker image with the manager. |
| 108 | +docker-build: generate ## Build docker image with the operator-controller. |
76 | 109 | docker build -t ${IMG} .
|
77 | 110 |
|
78 | 111 | .PHONY: docker-push
|
@@ -129,12 +162,24 @@ $(LOCALBIN):
|
129 | 162 | ## Tool Binaries
|
130 | 163 | KUSTOMIZE ?= $(LOCALBIN)/kustomize
|
131 | 164 | CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
|
| 165 | +KIND ?= $(LOCALBIN)/kind |
| 166 | +GINKGO ?= $(LOCALBIN)/ginkgo |
132 | 167 | ENVTEST ?= $(LOCALBIN)/setup-envtest
|
133 | 168 |
|
134 | 169 | ## Tool Versions
|
135 | 170 | KUSTOMIZE_VERSION ?= v4.5.7
|
136 | 171 | CONTROLLER_TOOLS_VERSION ?= v0.10.0
|
137 | 172 |
|
| 173 | +.PHONY: kind |
| 174 | +kind: $(KIND) ## Download kind locally if necessary. |
| 175 | +$(KIND): $(LOCALBIN) |
| 176 | + test -s $(LOCALBIN)/kind || GOBIN= $(LOCALBIN) go install sigs.k8s.io/ [email protected] |
| 177 | + |
| 178 | +.PHONY: ginkgo |
| 179 | +ginkgo: $(GINKGO) ## Download ginkgo locally if necessary. |
| 180 | +$(GINKGO): $(LOCALBIN) |
| 181 | + test -s $(LOCALBIN)/ginkgo || GOBIN= $(LOCALBIN) go install github.com/onsi/ginkgo/v2/ [email protected] |
| 182 | + |
138 | 183 | KUSTOMIZE_INSTALL_SCRIPT ?= "https://github.com/raw/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
|
139 | 184 | .PHONY: kustomize
|
140 | 185 | kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
|
|
0 commit comments