Skip to content

Commit

Permalink
makefile: render bundles using opm outside of the container
Browse files Browse the repository at this point in the history
using opm outside of the container does allow to use the local bundle
images as well. Which help to pull odf bundle image from the local
registry.

Signed-off-by: Nitin Goyal <[email protected]>
  • Loading branch information
iamniting committed Sep 19, 2022
1 parent 893bf9a commit f6b0051
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 18 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ bundle-push: ## Push the bundle image.
# This recipe invokes 'opm' in 'semver' bundle add mode. For more information on add modes, see:
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
.PHONY: catalog-build
catalog-build: ## Build a catalog image.
docker build --no-cache --build-arg BUNDLE_IMGS=${BUNDLE_IMGS} -f catalog.Dockerfile -t $(CATALOG_IMG) .
catalog-build: opm ## Build a catalog image.
$(OPM) render --output=yaml $(BUNDLE_IMGS) $(OPM_RENDER_OPTS) > catalog/bundle.yaml
$(OPM) validate catalog
docker build -f catalog.Dockerfile -t $(CATALOG_IMG) .

# Push the catalog image.
.PHONY: catalog-push
Expand Down
12 changes: 1 addition & 11 deletions catalog.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
FROM quay.io/operator-framework/upstream-opm-builder:v1.20.0 AS builder

ARG BUNDLE_IMGS=quay.io/ocs-dev/odf-operator-bundle:latest

# Copy declarative config root into image at /configs
ADD catalog /configs

RUN opm render --output=yaml ${BUNDLE_IMGS} > /configs/bundle.yaml
RUN opm validate /configs

# The base image is expected to contain
# /bin/opm (with a serve subcommand) and /bin/grpc_health_probe
FROM quay.io/operator-framework/opm:v1.26.0
Expand All @@ -17,7 +7,7 @@ ENTRYPOINT ["/bin/opm"]
CMD ["serve", "/configs"]

# Copy declarative config root into image at /configs
COPY --from=builder /configs /configs
COPY catalog /configs

# Set DC-specific label for the location of the DC root directory in the image
LABEL operators.operatorframework.io.index.configs.v1=/configs
5 changes: 4 additions & 1 deletion hack/make-bundle-vars.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ BUNDLE_CHANNELS := --channels=$(CHANNELS)

BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)

# OPM_RENDER_OPTS will be used while rendring bundle images
OPM_RENDER_OPTS ?=

# Each CSV has the option to specify an annotation 'operators.operatorframework.io/operator-type',
# which is an annotation that is (only!) read by the OLM Console UI to determine the visibility of
# the Operator package/bundle in the Operator Hub UI.
Expand Down Expand Up @@ -91,7 +94,7 @@ ODF_CONSOLE_IMG ?= $(ODF_CONSOLE_IMG_LOCATION)/$(ODF_CONSOLE_IMG_NAME):$(ODF_CON

# A space-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).
# These images MUST exist in a registry and be pull-able.
BUNDLE_IMGS ?= "$(BUNDLE_IMG) $(OCS_BUNDLE_IMG) $(IBM_BUNDLE_IMG) $(NOOBAA_BUNDLE_IMG) $(CSIADDONS_BUNDLE_IMG)"
BUNDLE_IMGS ?= $(BUNDLE_IMG) $(OCS_BUNDLE_IMG) $(IBM_BUNDLE_IMG) $(NOOBAA_BUNDLE_IMG) $(CSIADDONS_BUNDLE_IMG)

# Set CATALOG_BASE_IMG to an existing catalog image tag to add $BUNDLE_IMGS to that image.
ifneq ($(origin CATALOG_BASE_IMG), undefined)
Expand Down
10 changes: 6 additions & 4 deletions hack/make-tools.mk
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# go-get-tool will 'go get' any package $2 and install it to $1.
define go-get-tool
@[ -f $(1) ] || { \
echo "Downloading $(2)" ;\
GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
}
@[ -f $(1) ] || echo "Downloading $(2)"; GOBIN=$(PROJECT_DIR)/bin go install $(2)
endef

##@ Tools
Expand All @@ -23,3 +20,8 @@ ginkgo: ## Download ginkgo locally if necessary.
OPERATOR_SDK = $(BIN_DIR)/operator-sdk
operator-sdk: ## Download operator-sdk locally if necessary.
@./hack/get-tool.sh $(OPERATOR_SDK) https://github.com/operator-framework/operator-sdk/releases/download/v1.14.0/operator-sdk_$(GOOS)_$(GOARCH)

.PHONY: opm
OPM = $(BIN_DIR)/opm
opm: ## Download opm locally if necessary.
@./hack/get-tool.sh $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.22.0/$(GOOS)-$(GOARCH)-opm

0 comments on commit f6b0051

Please sign in to comment.