@@ -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,32 @@ 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+ # Address of the container registry
20+ REGISTRY = quay.io
21+
22+ # Organization in container resgistry
23+ ORG ?= 3scale
24+ REPO_NAME ?= 3scale-operator
25+
26+ # IMAGE_TAG_BASE defines the docker.io namespace and part of the image name for remote images.
27+ # This variable is used to construct full image tags for bundle and catalog images.
28+ #
29+ # For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
30+ # quay.io/kuadrant/limitador-operator-bundle:$VERSION and quay.io/kuadrant/limitador-operator-catalog:$VERSION.
31+ IMAGE_TAG_BASE ?= $(REGISTRY ) /$(ORG ) /$(REPO_NAME )
32+
33+ # Default bundle image tag
34+ BUNDLE_IMG ?= $(IMAGE_TAG_BASE ) -bundle:v$(VERSION )
35+
2036# Image URL to use all building/pushing image targets
21- IMG ?= quay.io/3scale/3scale-operator:master
37+ IMG ?= $(IMAGE_TAG_BASE ) :master
38+
39+ # 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).
40+ # These images MUST exist in a registry and be pull-able.
41+ BUNDLE_IMGS ?= $(BUNDLE_IMG )
42+
43+ # The image tag given to the resulting catalog image (e.g. make catalog-build CATALOG_IMG=example.com/operator-catalog:v0.2.0).
44+ CATALOG_IMG ?= $(IMAGE_TAG_BASE ) -catalog:v$(VERSION )
2245
2346CRD_OPTIONS ?= "crd:crdVersions=v1"
2447
@@ -294,6 +317,41 @@ bundle-custom-build: | bundle-custom-updates bundle-build bundle-restore
294317bundle-run : $(OPERATOR_SDK )
295318 $(OPERATOR_SDK ) run bundle --namespace openshift-marketplace $(BUNDLE_IMG )
296319
320+ .PHONY : opm
321+ OPM = $(LOCALBIN ) /opm
322+ opm : # # Download opm locally if necessary.
323+ ifeq (,$(wildcard $(OPM ) ) )
324+ ifeq (,$(shell which opm 2>/dev/null) )
325+ @{ \
326+ set -e ;\
327+ mkdir -p $(dir $(OPM)) ;\
328+ OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \
329+ curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.55.0/$${OS}-$${ARCH}-opm ;\
330+ chmod +x $(OPM) ;\
331+ }
332+ else
333+ OPM = $(shell which opm)
334+ endif
335+ endif
336+
337+
338+ # Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
339+ ifneq ($(origin CATALOG_BASE_IMG ) , undefined)
340+ FROM_INDEX_OPT := --from-index $(CATALOG_BASE_IMG )
341+ endif
342+
343+ # Build a catalog image by adding bundle images to an empty catalog using the operator package manager tool, 'opm'.
344+ # This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
345+ # https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
346+ .PHONY : catalog-build
347+ catalog-build : opm # # Build a catalog image.
348+ $(OPM ) index add --container-tool $(DOCKER ) --mode semver --tag $(CATALOG_IMG ) --bundles $(BUNDLE_IMGS ) $(FROM_INDEX_OPT )
349+
350+ # Push the catalog image.
351+ .PHONY : catalog-push
352+ catalog-push : # # Push a catalog image.
353+ $(DOCKER ) push ${CATALOG_IMG}
354+
297355# 3scale-specific targets
298356
299357# find or download yq
0 commit comments