2
2
# Configuration Variables #
3
3
# ##########################
4
4
# Image URL to use all building/pushing image targets
5
- export IMAGE_REPO ?= quay.io/operator-framework/operator-controller
6
- export IMAGE_TAG ?= devel
7
- export CERT_MGR_VERSION ?= v1.9.0
8
- export CATALOGD_VERSION ?= $(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/catalogd)
9
- export KAPP_VERSION ?= $(shell go list -mod=mod -m -f "{{.Version}}" github.com/vmware-tanzu/carvel-kapp-controller)
10
- export RUKPAK_VERSION =$(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/rukpak)
11
- export WAIT_TIMEOUT ?= 60s
12
- IMG? =$(IMAGE_REPO ) :$(IMAGE_TAG )
13
- TESTDATA_DIR := testdata
5
+ ifeq (, $(IMAGE_REPO ) )
6
+ IMAGE_REPO := quay.io/operator-framework/operator-controller
7
+ endif
8
+ export IMAGE_REPO
9
+
10
+ ifeq (, $(IMAGE_TAG ) )
11
+ IMAGE_TAG := devel
12
+ endif
13
+ export IMAGE_TAG
14
+
15
+ IMG := $(IMAGE_REPO ) :$(IMAGE_TAG )
16
+
17
+
18
+ # Define dependency versions (use go.mod if we also use Go code from dependency)
19
+ export CERT_MGR_VERSION := v1.9.0
20
+ export CATALOGD_VERSION := $(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/catalogd)
21
+ export KAPP_VERSION := $(shell go list -mod=mod -m -f "{{.Version}}" github.com/vmware-tanzu/carvel-kapp-controller)
22
+ export RUKPAK_VERSION := $(shell go list -mod=mod -m -f "{{.Version}}" github.com/operator-framework/rukpak)
23
+ export WAIT_TIMEOUT := 60s
14
24
15
25
# By default setup-envtest will write to $XDG_DATA_HOME, or $HOME/.local/share if that is not defined.
16
26
# If $HOME is not set, we need to specify a binary directory to prevent an error in setup-envtest.
@@ -23,34 +33,28 @@ endif
23
33
# bingo manages consistent tooling versions for things like kind, kustomize, etc.
24
34
include .bingo/Variables.mk
25
35
26
- # ARTIFACT_PATH is the absolute path to the directory where the operator-controller e2e tests will store the artifacts
27
- # for example: ARTIFACT_PATH=/tmp/artifacts make test
28
- export ARTIFACT_PATH ?=
29
-
30
- OPERATOR_CONTROLLER_NAMESPACE ?= operator-controller-system
31
- KIND_CLUSTER_NAME ?= operator-controller
36
+ KIND_CLUSTER_NAME := operator-controller
32
37
# Not guaranteed to have patch releases available and node image tags are full versions (i.e v1.28.0 - no v1.28, v1.29, etc.)
33
38
# The KIND_NODE_VERSION is set by getting the version of the k8s.io/client-go dependency from the go.mod
34
39
# and sets major version to "1" and the patch version to "0". For example, a client-go version of v0.28.5
35
40
# will map to a KIND_NODE_VERSION of 1.28.0
36
- KIND_NODE_VERSION = $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\) \.[[:digit:]]\{1,\}$$/1.\1.0/')
37
- KIND_CLUSTER_IMAGE ?= kindest/node:v${KIND_NODE_VERSION}
38
-
39
- CONTAINER_RUNTIME ?= docker
41
+ KIND_NODE_VERSION := $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\) \.[[:digit:]]\{1,\}$$/1.\1.0/')
42
+ KIND_CLUSTER_IMAGE := kindest/node:v$(KIND_NODE_VERSION )
40
43
41
- KUSTOMIZE_BUILD_DIR ?= config/default
42
-
43
- # Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
44
- ifeq (,$(shell go env GOBIN) )
45
- GOBIN =$(shell go env GOPATH) /bin
44
+ ifneq (, $(shell command -v docker 2>/dev/null) )
45
+ CONTAINER_RUNTIME := docker
46
+ else ifneq (, $(shell command -v podman 2>/dev/null))
47
+ CONTAINER_RUNTIME := podman
46
48
else
47
- GOBIN = $( shell go env GOBIN )
49
+ $(error Could not find docker or podman in path! )
48
50
endif
49
51
52
+ KUSTOMIZE_BUILD_DIR := config/default
53
+
50
54
# Setting SHELL to bash allows bash commands to be executed by recipes.
51
55
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
52
- SHELL = /usr/bin/env bash -o pipefail
53
- .SHELLFLAGS = -ec
56
+ SHELL : = /usr/bin/env bash -o pipefail
57
+ .SHELLFLAGS : = -ec
54
58
55
59
# Disable -j flag for make
56
60
.NOTPARALLEL :
@@ -83,7 +87,7 @@ help-extended: #HELP Display extended help.
83
87
84
88
.PHONY : lint
85
89
lint : $(GOLANGCI_LINT ) # HELP Run golangci linter.
86
- $(GOLANGCI_LINT ) run --build-tags $( GO_BUILD_TAGS ) $(GOLANGCI_LINT_ARGS )
90
+ $(GOLANGCI_LINT ) run $(GOLANGCI_LINT_ARGS )
87
91
88
92
.PHONY : tidy
89
93
tidy : # HELP Update dependencies.
@@ -114,38 +118,38 @@ test: manifests generate fmt vet test-unit test-e2e #HELP Run all tests.
114
118
115
119
.PHONY : e2e
116
120
e2e : $(SETUP_ENVTEST ) # EXHELP Run the e2e tests.
117
- go test -tags $( GO_BUILD_TAGS ) - v ./test/e2e/...
121
+ go test -v ./test/e2e/...
118
122
119
- export REG_PKG_NAME =registry-operator
120
- export PLAIN_PKG_NAME =plain-operator
121
- export CATALOG_IMG=${E2E_REGISTRY_NAME}.${E2E_REGISTRY_NAMESPACE}.svc :5000/test-catalog:e2e
123
+ E2E_REGISTRY_NAME := docker-registry
124
+ E2E_REGISTRY_NAMESPACE := operator-controller-e2e
125
+ export REG_PKG_NAME := registry-operator
126
+ export PLAIN_PKG_NAME := plain-operator
127
+ export CATALOG_IMG := $(E2E_REGISTRY_NAME ) .$(E2E_REGISTRY_NAMESPACE ) .svc:5000/test-catalog:e2e
122
128
.PHONY : test-ext-dev-e2e
123
129
test-ext-dev-e2e : $(SETUP_ENVTEST ) $(OPERATOR_SDK ) $(KUSTOMIZE ) $(KIND ) # HELP Run extension create, upgrade and delete tests.
124
- test/extension-developer-e2e/setup.sh $(OPERATOR_SDK ) $(CONTAINER_RUNTIME ) $(KUSTOMIZE ) $(KIND ) $(KIND_CLUSTER_NAME ) ${ E2E_REGISTRY_NAMESPACE}
125
- go test -tags $( GO_BUILD_TAGS ) - v ./test/extension-developer-e2e/...
130
+ test/extension-developer-e2e/setup.sh $(OPERATOR_SDK ) $(CONTAINER_RUNTIME ) $(KUSTOMIZE ) $(KIND ) $(KIND_CLUSTER_NAME ) $( E2E_REGISTRY_NAMESPACE )
131
+ go test -v ./test/extension-developer-e2e/...
126
132
127
133
.PHONY : test-unit
128
- ENVTEST_VERSION = $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\) \.[[:digit:]]\{1,\}$$/1.\1.x/')
129
- UNIT_TEST_DIRS = $(shell go list ./... | grep -v /test/)
134
+ ENVTEST_VERSION : = $(shell go list -m k8s.io/client-go | cut -d" " -f2 | sed 's/^v0\.\([[:digit:]]\{1,\}\) \.[[:digit:]]\{1,\}$$/1.\1.x/')
135
+ UNIT_TEST_DIRS := $(shell go list ./... | grep -v /test/)
130
136
test-unit : $(SETUP_ENVTEST ) # HELP Run the unit tests
131
- eval $$($(SETUP_ENVTEST ) use -p env $(ENVTEST_VERSION ) $(SETUP_ENVTEST_BIN_DIR_OVERRIDE ) ) && go test -tags $( GO_BUILD_TAGS ) - count=1 -short $(UNIT_TEST_DIRS ) -coverprofile cover.out
137
+ eval $$($(SETUP_ENVTEST ) use -p env $(ENVTEST_VERSION ) $(SETUP_ENVTEST_BIN_DIR_OVERRIDE ) ) && go test -count=1 -short $(UNIT_TEST_DIRS ) -coverprofile cover.out
132
138
133
- E2E_REGISTRY_NAME =docker-registry
134
- E2E_REGISTRY_NAMESPACE =operator-controller-e2e
135
139
image-registry : # # Setup in-cluster image registry
136
- ./test/tools/image-registry.sh ${ E2E_REGISTRY_NAMESPACE} ${ E2E_REGISTRY_NAME}
140
+ ./test/tools/image-registry.sh $( E2E_REGISTRY_NAMESPACE ) $( E2E_REGISTRY_NAME )
137
141
138
142
build-push-e2e-catalog : # # Build the testdata catalog used for e2e tests and push it to the image registry
139
- ./test/tools/build-push-e2e-catalog.sh ${ E2E_REGISTRY_NAMESPACE} ${ CATALOG_IMG}
143
+ ./test/tools/build-push-e2e-catalog.sh $( E2E_REGISTRY_NAMESPACE ) $( CATALOG_IMG )
140
144
141
145
.PHONY : test-e2e
142
- test-e2e : KIND_CLUSTER_NAME= operator-controller-e2e
143
- test-e2e : KUSTOMIZE_BUILD_DIR= config/e2e
144
- test-e2e : GO_BUILD_FLAGS= -cover
146
+ test-e2e : KIND_CLUSTER_NAME := operator-controller-e2e
147
+ test-e2e : KUSTOMIZE_BUILD_DIR := config/e2e
148
+ test-e2e : GO_BUILD_FLAGS := -cover
145
149
test-e2e : run image-registry build-push-e2e-catalog kind-load-test-artifacts e2e e2e-coverage kind-clean # HELP Run e2e test suite on local kind cluster
146
150
147
151
.PHONY : extension-developer-e2e
148
- extension-developer-e2e : KIND_CLUSTER_NAME= operator-controller-ext-dev-e2e # EXHELP Run extension-developer e2e on local kind cluster
152
+ extension-developer-e2e : KIND_CLUSTER_NAME := operator-controller-ext-dev-e2e # EXHELP Run extension-developer e2e on local kind cluster
149
153
extension-developer-e2e : run image-registry test-ext-dev-e2e kind-clean
150
154
151
155
.PHONY : e2e-coverage
@@ -156,29 +160,29 @@ e2e-coverage:
156
160
kind-load : $(KIND ) # EXHELP Loads the currently constructed image onto the cluster.
157
161
$(CONTAINER_RUNTIME ) save $(IMG ) | $(KIND ) load image-archive /dev/stdin --name $(KIND_CLUSTER_NAME )
158
162
159
- kind-deploy : export MANIFEST=" ./operator-controller.yaml"
163
+ kind-deploy : export MANIFEST := ./operator-controller.yaml
160
164
kind-deploy : manifests $(KUSTOMIZE ) # EXHELP Install controller and dependencies onto the kind cluster.
161
165
$(KUSTOMIZE ) build $(KUSTOMIZE_BUILD_DIR ) > operator-controller.yaml
162
166
envsubst ' $$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$KAPP_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh | bash -s
163
167
164
168
.PHONY : kind-cluster
165
169
kind-cluster : $(KIND ) # EXHELP Standup a kind cluster.
166
- -$(KIND ) delete cluster --name ${ KIND_CLUSTER_NAME}
170
+ -$(KIND ) delete cluster --name $( KIND_CLUSTER_NAME )
167
171
# kind-config.yaml can be deleted after upgrading to Kubernetes 1.30
168
- $(KIND ) create cluster --name ${ KIND_CLUSTER_NAME} --image ${ KIND_CLUSTER_IMAGE} --config ./kind-config.yaml
169
- $(KIND ) export kubeconfig --name ${ KIND_CLUSTER_NAME}
172
+ $(KIND ) create cluster --name $( KIND_CLUSTER_NAME ) --image $( KIND_CLUSTER_IMAGE ) --config ./kind-config.yaml
173
+ $(KIND ) export kubeconfig --name $( KIND_CLUSTER_NAME )
170
174
171
175
.PHONY : kind-clean
172
176
kind-clean : $(KIND ) # EXHELP Delete the kind cluster.
173
- $(KIND ) delete cluster --name ${ KIND_CLUSTER_NAME}
177
+ $(KIND ) delete cluster --name $( KIND_CLUSTER_NAME )
174
178
175
179
.PHONY : kind-load-test-artifacts
176
180
kind-load-test-artifacts : $(KIND ) # EXHELP Load the e2e testdata container images into a kind cluster.
177
- $(CONTAINER_RUNTIME ) build $( TESTDATA_DIR ) /bundles/registry-v1/prometheus-operator.v1.0.0 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.0
181
+ $(CONTAINER_RUNTIME ) build testdata /bundles/registry-v1/prometheus-operator.v1.0.0 -t localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.0
178
182
$(CONTAINER_RUNTIME ) tag localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.0 localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.1
179
183
$(CONTAINER_RUNTIME ) tag localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.0 localhost/testdata/bundles/registry-v1/prometheus-operator:v1.2.0
180
184
$(CONTAINER_RUNTIME ) tag localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.0 localhost/testdata/bundles/registry-v1/prometheus-operator:v2.0.0
181
- $(CONTAINER_RUNTIME ) build $( TESTDATA_DIR ) /bundles/plain-v0/plain.v0.1.0 -t localhost/testdata/bundles/plain-v0/plain:v0.1.0
185
+ $(CONTAINER_RUNTIME ) build testdata /bundles/plain-v0/plain.v0.1.0 -t localhost/testdata/bundles/plain-v0/plain:v0.1.0
182
186
$(KIND ) load docker-image localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.0 --name $(KIND_CLUSTER_NAME )
183
187
$(KIND ) load docker-image localhost/testdata/bundles/registry-v1/prometheus-operator:v1.0.1 --name $(KIND_CLUSTER_NAME )
184
188
$(KIND ) load docker-image localhost/testdata/bundles/registry-v1/prometheus-operator:v1.2.0 --name $(KIND_CLUSTER_NAME )
@@ -188,28 +192,35 @@ kind-load-test-artifacts: $(KIND) #EXHELP Load the e2e testdata container images
188
192
189
193
# SECTION Build
190
194
191
- export VERSION ?= $(shell git describe --tags --always --dirty)
192
- export CGO_ENABLED ?= 0
193
- export GO_BUILD_ASMFLAGS ?= all=-trimpath=${PWD}
194
- export GO_BUILD_LDFLAGS ?= -s -w -X $(shell go list -m) /version.Version=$(VERSION )
195
- export GO_BUILD_GCFLAGS ?= all=-trimpath=${PWD}
196
- export GO_BUILD_TAGS ?= upstream
197
- export GO_BUILD_FLAGS ?=
195
+ ifeq (,$(VERSION ) )
196
+ VERSION := $(shell git describe --tags --always --dirty)
197
+ endif
198
+ export VERSION
199
+
200
+ ifeq (,$(CGO_ENABLED ) )
201
+ CGO_ENABLED := 0
202
+ endif
203
+ export CGO_ENABLED
204
+
205
+ export GO_BUILD_ASMFLAGS := all=-trimpath=$(PWD )
206
+ export GO_BUILD_LDFLAGS := -s -w -X $(shell go list -m) /version.Version=$(VERSION )
207
+ export GO_BUILD_GCFLAGS := all=-trimpath=$(PWD )
208
+ export GO_BUILD_FLAGS :=
198
209
199
- 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
210
+ BUILDCMD = go build $(GO_BUILD_FLAGS ) -ldflags '$(GO_BUILD_LDFLAGS ) ' -gcflags '$(GO_BUILD_GCFLAGS ) ' -asmflags '$(GO_BUILD_ASMFLAGS ) ' -o $(BUILDBIN ) /manager ./cmd/manager
200
211
201
212
.PHONY : build-deps
202
213
build-deps : manifests generate fmt vet
203
214
204
215
.PHONY : build go-build-local
205
216
build : build-deps go-build-local # HELP Build manager binary for current GOOS and GOARCH. Default target.
206
- go-build-local : BUILDBIN = bin
217
+ go-build-local : BUILDBIN : = bin
207
218
go-build-local :
208
219
$(BUILDCMD )
209
220
210
221
.PHONY : build-linux go-build-linux
211
222
build-linux : build-deps go-build-linux # EXHELP Build manager binary for GOOS=linux and local GOARCH.
212
- go-build-linux : BUILDBIN = bin/linux
223
+ go-build-linux : BUILDBIN : = bin/linux
213
224
go-build-linux :
214
225
GOOS=linux $(BUILDCMD )
215
226
@@ -218,27 +229,33 @@ run: docker-build kind-cluster kind-load kind-deploy #HELP Build the operator-co
218
229
219
230
.PHONY : docker-build
220
231
docker-build : build-linux # EXHELP Build docker image for operator-controller with GOOS=linux and local GOARCH.
221
- $(CONTAINER_RUNTIME ) build -t ${ IMG} -f Dockerfile ./bin/linux
232
+ $(CONTAINER_RUNTIME ) build -t $( IMG ) -f Dockerfile ./bin/linux
222
233
223
234
# SECTION Release
235
+ ifeq (, $(ENABLE_RELEASE_PIPELINE ) )
236
+ ENABLE_RELEASE_PIPELINE := false
237
+ endif
238
+ ifeq (, $(GORELEASER_ARGS ) )
239
+ GORELEASER_ARGS := --snapshot --clean
240
+ endif
224
241
225
- export ENABLE_RELEASE_PIPELINE ?= false
226
- export GORELEASER_ARGS ?= --snapshot --clean
242
+ export ENABLE_RELEASE_PIPELINE
243
+ export GORELEASER_ARGS
227
244
228
245
.PHONY : release
229
246
release : $(GORELEASER ) # EXHELP 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.
230
247
$(GORELEASER ) $(GORELEASER_ARGS )
231
248
232
249
.PHONY : quickstart
233
- quickstart : export MANIFEST=" https://github.com/operator-framework/operator-controller/releases/download/$(VERSION ) /operator-controller.yaml"
250
+ quickstart : export MANIFEST := https://github.com/operator-framework/operator-controller/releases/download/$(VERSION ) /operator-controller.yaml
234
251
quickstart : $(KUSTOMIZE ) manifests # EXHELP Generate the installation release manifests and scripts.
235
252
$(KUSTOMIZE ) build $(KUSTOMIZE_BUILD_DIR ) | sed " s/:devel/:$( VERSION) /g" > operator-controller.yaml
236
253
envsubst ' $$CATALOGD_VERSION,$$CERT_MGR_VERSION,$$KAPP_VERSION,$$RUKPAK_VERSION,$$MANIFEST' < scripts/install.tpl.sh > install.sh
237
254
238
255
# #@ Docs
239
256
240
- VENVDIR = $(abspath docs/.venv)
241
- REQUIREMENTS_TXT = docs/requirements.txt
257
+ VENVDIR := $(abspath docs/.venv)
258
+ REQUIREMENTS_TXT := docs/requirements.txt
242
259
243
260
.PHONY : build-docs
244
261
build-docs : venv
0 commit comments