|
4 | 4 | # - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2) |
5 | 5 | # - use environment variables to overwrite this value (e.g export VERSION=0.0.2) |
6 | 6 | VERSION ?= 0.0.4 |
| 7 | +SUPPORTED_OCP_VERSIONS ?= v4.20-v4.21 |
7 | 8 | OPERATOR_NAME ?= patterns |
8 | 9 | GOFLAGS=-mod=vendor |
9 | 10 | REGISTRY ?= localhost |
10 | 11 | UPLOADREGISTRY ?= quay.io/validatedpatterns |
11 | 12 | GOLANGCI_IMG ?= docker.io/golangci/golangci-lint |
12 | 13 | GOLANGCI_VERSION ?= 2.11.3 |
13 | 14 |
|
| 15 | + |
14 | 16 | # CI uses a non-writable home dir, make sure .cache is writable |
15 | 17 | ifeq ("${HOME}", "/") |
16 | 18 | HOME=/tmp |
@@ -69,6 +71,13 @@ BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION) |
69 | 71 | # Image URL to use all building/pushing image targets |
70 | 72 | IMG ?= $(IMAGE_TAG_BASE):$(VERSION) |
71 | 73 | OPERATOR_IMG ?= $(OPERATOR_NAME)-operator:$(VERSION) |
| 74 | + |
| 75 | +# always release the console with the same tag as the operator and the other way around! |
| 76 | +# Image base URL of the console plugin |
| 77 | +CONSOLE_PLUGIN_IMAGE_BASE ?= $(IMAGE_TAG_BASE)-console |
| 78 | +CONSOLE_PLUGIN_IMAGE ?= $(CONSOLE_PLUGIN_IMAGE_BASE):$(VERSION) |
| 79 | +CONSOLE_PLUGIN_DOCKERFILE ?= console-plugin.Dockerfile |
| 80 | + |
72 | 81 | # ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary. |
73 | 82 | ENVTEST_K8S_VERSION = 1.30 |
74 | 83 |
|
@@ -205,11 +214,16 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified |
205 | 214 | .PHONY: deploy |
206 | 215 | deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config. |
207 | 216 | cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} |
| 217 | + cd config/console-plugin && $(KUSTOMIZE) edit set image console-plugin=${CONSOLE_PLUGIN_IMAGE} |
208 | 218 | $(KUSTOMIZE) build config/default | kubectl apply -f - |
| 219 | + $(KUSTOMIZE) build config/console-plugin | kubectl apply -f - |
| 220 | + $(KUSTOMIZE) build config/pattern-ui-catalog | kubectl apply -f - |
209 | 221 |
|
210 | 222 | .PHONY: undeploy |
211 | 223 | 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. |
212 | 224 | $(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f - |
| 225 | + $(KUSTOMIZE) build config/console-plugin | kubectl delete --ignore-not-found=$(ignore-not-found) -f - |
| 226 | + $(KUSTOMIZE) build config/pattern-ui-catalog | kubectl delete --ignore-not-found=$(ignore-not-found) -f - |
213 | 227 |
|
214 | 228 | ## Location to install dependencies to |
215 | 229 | LOCALBIN ?= $(shell pwd)/bin |
@@ -293,6 +307,7 @@ endef |
293 | 307 | bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metadata, then validate generated files. |
294 | 308 | $(OPERATOR_SDK) generate kustomize manifests -q |
295 | 309 | cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG) |
| 310 | + cd config/console-plugin && $(KUSTOMIZE) edit set image console-plugin=$(CONSOLE_PLUGIN_IMAGE) |
296 | 311 | $(KUSTOMIZE) build config/manifests | $(OPERATOR_SDK) generate bundle $(BUNDLE_GEN_FLAGS) |
297 | 312 | $(MAKE) bundle-fixes bundle-date |
298 | 313 | ./hack/set_openshift_minimum_version.sh |
@@ -352,6 +367,22 @@ ifneq ($(origin CATALOG_BASE_IMG), undefined) |
352 | 367 | FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG) |
353 | 368 | endif |
354 | 369 |
|
| 370 | +# Generate Dockerfile using the template. It uses envsubst to replace the value of the version label in the container |
| 371 | +.PHONY: generate-dockerfile-console-plugin |
| 372 | +generate-dockerfile-console-plugin: |
| 373 | + VERSION=$(VERSION) SUPPORTED_OCP_VERSIONS=$(SUPPORTED_OCP_VERSIONS) envsubst < templates/console-plugin.Dockerfile.template > $(CONSOLE_PLUGIN_DOCKERFILE) |
| 374 | + |
| 375 | +.PHONY: console-build |
| 376 | +console-build: generate-dockerfile-console-plugin ## Build the console image |
| 377 | + @echo "Building console image with cache optimization..." |
| 378 | + @podman pull $(CONSOLE_PLUGIN_IMAGE_BASE):latest 2>/dev/null || true |
| 379 | + podman build -f $(CURPATH)/$(CONSOLE_PLUGIN_DOCKERFILE) -t ${CONSOLE_PLUGIN_IMAGE} . |
| 380 | + podman tag ${CONSOLE_PLUGIN_IMAGE} $(CONSOLE_PLUGIN_IMAGE_BASE):latest |
| 381 | + |
| 382 | +.PHONY: console-push |
| 383 | +console-push: ## Push the console image |
| 384 | + podman push $(CONSOLE_PLUGIN_IMAGE) |
| 385 | + |
355 | 386 | # Build an OLM catalog image by adding the bundle image to a simple catalog using the |
356 | 387 | # operator package manager tool, 'opm'. For more information see: |
357 | 388 | # https://olm.operatorframework.io/docs/reference/catalog-templates |
|
0 commit comments