@@ -3,8 +3,7 @@ SHELL := /bin/bash
33VERSION ?= 0.0.1
44# Current Threescale version
55THREESCALE_VERSION ?= 2.16
6- # Default bundle image tag
7- BUNDLE_IMG ?= controller-bundle:$(VERSION )
6+
87# Options for 'bundle-build'
98ifneq ($(origin CHANNELS ) , undefined)
109BUNDLE_CHANNELS := --channels=$(CHANNELS )
@@ -17,8 +16,20 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
1716OS := $(shell uname | awk '{print tolower($$0) }' | sed -e s/linux/linux-gnu/ )
1817ARCH := $(shell uname -m)
1918
19+ IMAGE_TAG_BASE ?= quay.io/3scale-operator
20+
21+ # Default bundle image tag
22+ BUNDLE_IMG ?= $(IMAGE_TAG_BASE ) -bundle:v$(VERSION )
23+
2024# Image URL to use all building/pushing image targets
21- IMG ?= quay.io/3scale/3scale-operator:master
25+ IMG ?= $(IMAGE_TAG_BASE ) :master
26+
27+ # A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0).
28+ # These images MUST exist in a registry and be pull-able.
29+ BUNDLE_IMGS ?= $(BUNDLE_IMG )
30+
31+ # The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
32+ CATALOG_IMG ?= $(IMAGE_TAG_BASE ) -catalog:v$(VERSION )
2233
2334CRD_OPTIONS ?= "crd:crdVersions=v1"
2435
@@ -294,6 +305,41 @@ bundle-custom-build: | bundle-custom-updates bundle-build bundle-restore
294305bundle-run : $(OPERATOR_SDK )
295306 $(OPERATOR_SDK ) run bundle --namespace openshift-marketplace $(BUNDLE_IMG )
296307
308+ .PHONY : opm
309+ OPM = $(LOCALBIN ) /opm
310+ opm : # # Download opm locally if necessary.
311+ ifeq (,$(wildcard $(OPM ) ) )
312+ ifeq (,$(shell which opm 2>/dev/null) )
313+ @{ \
314+ set -e ;\
315+ mkdir -p $(dir $(OPM)) ;\
316+ OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
317+ curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.55.0/$${OS}-$${ARCH}-opm ;\
318+ chmod +x $(OPM) ;\
319+ }
320+ else
321+ OPM = $(shell which opm)
322+ endif
323+ endif
324+
325+
326+ # Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
327+ ifneq ($(origin CATALOG_BASE_IMG ) , undefined)
328+ FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG )
329+ endif
330+
331+ # Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
332+ # This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
333+ # https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
334+ .PHONY : catalog-build
335+ catalog-build : opm # # Build a catalog image.
336+ $(OPM ) index add --container-tool $(DOCKER ) --mode semver --tag $(CATALOG_IMG ) --bundles $(BUNDLE_IMGS ) $(FROM_INDEX_OPT )
337+
338+ # Push the catalog image.
339+ .PHONY : catalog-push
340+ catalog-push : # # Push a catalog image.
341+ $(DOCKER ) push ${CATALOG_IMG}
342+
297343# 3scale-specific targets
298344
299345# find or download yq
0 commit comments