From 4a9aed0d46f3cc99e611517f93d00a4f55350fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Mac=C3=ADk?= Date: Fri, 24 Jun 2022 15:47:03 +0200 Subject: [PATCH] Change operator index image to file-based (#1179) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pavel MacĂ­k --- .github/actions/setup-podman/opm | 16 ++++++++++++++++ .github/workflows/pr-checks-build-images.yaml | 4 +++- make/build.mk | 17 ++++++++++++++++- make/common.mk | 4 ++-- 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100755 .github/actions/setup-podman/opm diff --git a/.github/actions/setup-podman/opm b/.github/actions/setup-podman/opm new file mode 100755 index 0000000000..5fef15e571 --- /dev/null +++ b/.github/actions/setup-podman/opm @@ -0,0 +1,16 @@ +#!/bin/bash +opm=$(readlink -m bin/opm) +podman="/usr/bin/podman" +local_image="localhost:5000/sbo:bundle" + +case "$1" in + render) + img=$2 + "$podman" tag $img $local_image + "$podman" push --tls-verify=false $local_image + "$opm" render $local_image --output=yaml --use-http | sed -e "s,$local_image,$img,g" + ;; + *) + "$opm" "$@" + ;; +esac diff --git a/.github/workflows/pr-checks-build-images.yaml b/.github/workflows/pr-checks-build-images.yaml index ac5e66101c..ee625d97f1 100644 --- a/.github/workflows/pr-checks-build-images.yaml +++ b/.github/workflows/pr-checks-build-images.yaml @@ -49,7 +49,9 @@ jobs: which podman - BUILDAH_FORMAT=docker make SKIP_REGISTRY_LOGIN=true release-operator -o registry-login + make opm + + OPM=.github/actions/setup-podman/opm BUILDAH_FORMAT=docker make SKIP_REGISTRY_LOGIN=true release-operator -o registry-login mkdir -p ${ARTIFACTS} diff --git a/make/build.mk b/make/build.mk index fd2541110a..9fd40146aa 100644 --- a/make/build.mk +++ b/make/build.mk @@ -7,6 +7,10 @@ CSV_PACKAGE_NAME ?= service-binding-operator BUNDLE_METADATA_OPTS ?= --channels=$(OPERATOR_CHANNELS) --default-channel=$(DEFAULT_OPERATOR_CHANNEL) +OPERATOR_INDEX_NAME ?= $(CSV_PACKAGE_NAME)-index +OPERATOR_INDEX_DIR ?= $(OPERATOR_INDEX_NAME) +OPERATOR_INDEX_YAML ?= $(OPERATOR_INDEX_DIR)/index.yaml + .PHONY: build ## Build operator binary build: @@ -54,7 +58,18 @@ push-bundle-image: bundle-image registry-login .PHONY: index-image index-image: opm push-bundle-image - $(OPM) index add -u $(CONTAINER_RUNTIME) -p $(CONTAINER_RUNTIME) --bundles $(OPERATOR_BUNDLE_IMAGE_REF) --tag $(OPERATOR_INDEX_IMAGE_REF) + mkdir -p $(OPERATOR_INDEX_DIR) + -$(OPM) generate dockerfile $(OPERATOR_INDEX_NAME) + $(OPM) init $(CSV_PACKAGE_NAME) --default-channel=$(DEFAULT_OPERATOR_CHANNEL) --icon=$(PROJECT_DIR)/assets/icon/sbo-logo.svg --output=yaml > $(OPERATOR_INDEX_YAML) + $(OPM) render $(OPERATOR_BUNDLE_IMAGE_REF) --output=yaml >> $(OPERATOR_INDEX_YAML) + @echo "---" >> $(OPERATOR_INDEX_YAML) + @echo "schema: olm.channel" >> $(OPERATOR_INDEX_YAML) + @echo "package: $(CSV_PACKAGE_NAME)" >> $(OPERATOR_INDEX_YAML) + @echo "name: $(DEFAULT_OPERATOR_CHANNEL)" >> $(OPERATOR_INDEX_YAML) + @echo "entries:" >> $(OPERATOR_INDEX_YAML) + @echo "- name: $(CSV_PACKAGE_NAME).v$(VERSION)" >> $(OPERATOR_INDEX_YAML) + $(OPM) validate $(OPERATOR_INDEX_NAME) + $(CONTAINER_RUNTIME) build -f $(OPERATOR_INDEX_NAME).Dockerfile -t $(OPERATOR_INDEX_IMAGE_REF) . .PHONY: push-index-image # push index image diff --git a/make/common.mk b/make/common.mk index 34058f2a07..246efd2f74 100644 --- a/make/common.mk +++ b/make/common.mk @@ -155,14 +155,14 @@ mockgen: $(call go-install-tool,$(MOCKGEN),github.com/golang/mock/mockgen@v1.6.0) .PHONY: opm -OPM = $(shell pwd)/bin/opm +OPM ?= $(shell pwd)/bin/opm opm: ifeq (,$(wildcard $(OPM))) ifeq (,$(shell which opm 2>/dev/null)) @{ \ set -e ;\ mkdir -p $(dir $(OPM)) ;\ - curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.19.1/$(OS)-$(ARCH)-opm ;\ + curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.22.0/$(OS)-$(ARCH)-opm ;\ chmod +x $(OPM) ;\ } else