@@ -24,6 +24,8 @@ KIND_CLUSTER_NAME ?= operator-controller
24
24
25
25
CONTAINER_RUNTIME ?= docker
26
26
27
+ KUSTOMIZE_BUILD_DIR ?= config/default
28
+
27
29
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
28
30
ifeq (,$(shell go env GOBIN) )
29
31
GOBIN =$(shell go env GOPATH) /bin
@@ -39,8 +41,7 @@ SHELL = /usr/bin/env bash -o pipefail
39
41
# Disable -j flag for make
40
42
.NOTPARALLEL :
41
43
42
- .PHONY : all
43
- all : build
44
+ .DEFAULT_GOAL := build
44
45
45
46
# #@ General
46
47
@@ -89,32 +90,45 @@ fmt: ## Run go fmt against code.
89
90
vet : # # Run go vet against code.
90
91
go vet ./...
91
92
92
- .PHONY : test test-e2e e2e kind-load kind-cluster kind-cluster-cleanup
93
+ .PHONY : test
93
94
test : manifests generate fmt vet test-unit e2e # # Run all tests.
94
95
96
+ .PHONY : test-e2e
95
97
FOCUS := $(if $(TEST ) ,-v -focus "$(TEST ) ")
96
98
E2E_FLAGS ?= ""
97
99
test-e2e : $(GINKGO ) # # Run the e2e tests
98
100
$(GINKGO ) --tags $(GO_BUILD_TAGS ) $(E2E_FLAGS ) -trace -progress $(FOCUS ) test/e2e
99
101
102
+ .PHONY : test-unit
100
103
ENVTEST_VERSION = $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\) \.[[:digit:]]\{1,\}$$/1.\1.x/')
101
104
UNIT_TEST_DIRS =$(shell go list ./... | grep -v /test/)
102
105
test-unit : $(SETUP_ENVTEST ) # # Run the unit tests
103
106
eval $$($(SETUP_ENVTEST ) use -p env $(ENVTEST_VERSION ) ) && go test -tags $(GO_BUILD_TAGS ) -count=1 -short $(UNIT_TEST_DIRS ) -coverprofile cover.out
104
107
108
+ .PHONY : e2e
105
109
e2e : KIND_CLUSTER_NAME=operator-controller-e2e
106
- e2e : run kind-load-test-artifacts test-e2e kind-cluster-cleanup # # Run e2e test suite on local kind cluster
110
+ e2e : KUSTOMIZE_BUILD_DIR=config/e2e
111
+ e2e : GO_BUILD_FLAGS=-cover
112
+ e2e : run kind-load-test-artifacts test-e2e e2e-coverage kind-cluster-cleanup # # Run e2e test suite on local kind cluster
113
+
114
+ .PHONY : e2e-coverage
115
+ e2e-coverage :
116
+ COVERAGE_OUTPUT=./e2e-cover.out ./hack/e2e-coverage.sh
107
117
118
+ .PHONY : kind-load
108
119
kind-load : $(KIND ) # # Loads the currently constructed image onto the cluster
109
120
$(KIND ) load docker-image $(IMG ) --name $(KIND_CLUSTER_NAME )
110
121
111
- kind-cluster : $(KIND ) kind-cluster-cleanup # # Standup a kind cluster
122
+ .PHONY : kind-cluster
123
+ kind-cluster : $(KIND ) # # Standup a kind cluster
112
124
$(KIND ) create cluster --name ${KIND_CLUSTER_NAME}
113
125
$(KIND ) export kubeconfig --name ${KIND_CLUSTER_NAME}
114
126
127
+ .PHONY : kind-cluster-cleanup
115
128
kind-cluster-cleanup : $(KIND ) # # Delete the kind cluster
116
129
$(KIND ) delete cluster --name ${KIND_CLUSTER_NAME}
117
130
131
+ .PHONY : kind-load-test-artifacts
118
132
kind-load-test-artifacts : $(KIND ) # # Load the e2e testdata container images into a kind cluster
119
133
$(CONTAINER_RUNTIME ) build $(TESTDATA_DIR ) /bundles/registry-v1/prometheus-operator.v0.37.0 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v0.37.0
120
134
$(CONTAINER_RUNTIME ) build $(TESTDATA_DIR ) /bundles/registry-v1/prometheus-operator.v0.47.0 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v0.47.0
@@ -135,8 +149,9 @@ export GO_BUILD_ASMFLAGS ?= all=-trimpath=${PWD}
135
149
export GO_BUILD_LDFLAGS ?= -s -w -X $(shell go list -m) /version.Version=$(VERSION )
136
150
export GO_BUILD_GCFLAGS ?= all=-trimpath=${PWD}
137
151
export GO_BUILD_TAGS ?= upstream
152
+ export GO_BUILD_FLAGS ?=
138
153
139
- BUILDCMD = go build -tags '$(GO_BUILD_TAGS ) ' -ldflags '$(GO_BUILD_LDFLAGS ) ' -gcflags '$(GO_BUILD_GCFLAGS ) ' -asmflags '$(GO_BUILD_ASMFLAGS ) ' -o $(BUILDBIN ) /manager ./cmd/manager
154
+ BUILDCMD = go build $( GO_BUILD_FLAGS ) -tags '$(GO_BUILD_TAGS ) ' -ldflags '$(GO_BUILD_LDFLAGS ) ' -gcflags '$(GO_BUILD_GCFLAGS ) ' -asmflags '$(GO_BUILD_ASMFLAGS ) ' -o $(BUILDBIN ) /manager ./cmd/manager
140
155
141
156
.PHONY : build-deps
142
157
build-deps : manifests generate fmt vet
@@ -156,10 +171,6 @@ go-build-linux:
156
171
.PHONY : run
157
172
run : docker-build kind-cluster kind-load install # # Build the operator-controller then deploy it into a new kind cluster.
158
173
159
- .PHONY : wait
160
- wait :
161
- kubectl wait --for=condition=Available --namespace=$(OPERATOR_CONTROLLER_NAMESPACE ) deployment/operator-controller-controller-manager --timeout=$(WAIT_TIMEOUT )
162
-
163
174
.PHONY : docker-build
164
175
docker-build : build-linux # # Build docker image for operator-controller with GOOS=linux and local GOARCH.
165
176
docker build -t ${IMG} -f Dockerfile ./bin/linux
@@ -172,12 +183,14 @@ docker-build: build-linux ## Build docker image for operator-controller with GOO
172
183
export ENABLE_RELEASE_PIPELINE ?= false
173
184
export GORELEASER_ARGS ?= --snapshot --clean
174
185
186
+ .PHONY : release
175
187
release : $(GORELEASER ) # # Runs goreleaser for the operator-controller. By default, this will run only as a snapshot and will not publish any artifacts unless it is run with different arguments. To override the arguments, run with "GORELEASER_ARGS=...". When run as a github action from a tag, this target will publish a full release.
176
188
$(GORELEASER ) $(GORELEASER_ARGS )
177
189
190
+ .PHONY : quickstart
178
191
quickstart : export MANIFEST="https://github.com/operator-framework/operator-controller/releases/download/$(VERSION ) /operator-controller.yaml"
179
192
quickstart : $(KUSTOMIZE ) generate # # Generate the installation release manifests and scripts
180
- $(KUSTOMIZE ) build config/default | sed " s/:devel/:$( VERSION) /g" > operator-controller.yaml
193
+ $(KUSTOMIZE ) build $( KUSTOMIZE_BUILD_DIR ) | sed " s/:devel/:$( VERSION) /g" > operator-controller.yaml
181
194
envsubst ' $$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh > install.sh
182
195
183
196
# #@ Deployment
@@ -189,7 +202,7 @@ endif
189
202
.PHONY : install
190
203
install : export MANIFEST="./operator-controller.yaml"
191
204
install : manifests $(KUSTOMIZE ) generate # # Install CRDs into the K8s cluster specified in ~/.kube/config.
192
- $(KUSTOMIZE ) build config/default > operator-controller.yaml
205
+ $(KUSTOMIZE ) build $( KUSTOMIZE_BUILD_DIR ) > operator-controller.yaml
193
206
envsubst ' $$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s
194
207
195
208
.PHONY : uninstall
@@ -199,8 +212,8 @@ uninstall: manifests $(KUSTOMIZE) ## Uninstall CRDs from the K8s cluster specifi
199
212
.PHONY : deploy
200
213
deploy : manifests $(KUSTOMIZE ) # # Deploy controller to the K8s cluster specified in ~/.kube/config.
201
214
cd config/manager && $(KUSTOMIZE ) edit set image controller=${IMG}
202
- $(KUSTOMIZE ) build config/default | kubectl apply -f -
215
+ $(KUSTOMIZE ) build $( KUSTOMIZE_BUILD_DIR ) | kubectl apply -f -
203
216
204
217
.PHONY : undeploy
205
218
undeploy : # # Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
206
- $(KUSTOMIZE ) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found ) -f -
219
+ $(KUSTOMIZE ) build $( KUSTOMIZE_BUILD_DIR ) | kubectl delete --ignore-not-found=$(ignore-not-found ) -f -
0 commit comments