Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ bin
.vscode

cache

# Catalog-related artifacts
catalog
catalog.Dockerfile
35 changes: 32 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ CSV_PATH=bundle/manifests/ibm-common-service-operator.clusterserviceversion.yaml
BUILD_LOCALLY ?= 1

VCS_REF ?= $(shell git rev-parse HEAD)
VERSION ?= $(shell git describe --exact-match 2> /dev/null || \
GIT_COMMIT_ID := $(shell git describe --exact-match 2> /dev/null || \
git describe --match=$(git rev-parse --short=8 HEAD) --always --dirty --abbrev=8)
VERSION ?= $(GIT_COMMIT_ID)
RELEASE_VERSION ?= $(shell cat ./version/version.go | grep "Version =" | awk '{ print $$3}' | tr -d '"')
PREVIOUS_VERSION := 3.23.0
LATEST_VERSION ?= 4.15.0
Expand All @@ -52,7 +53,7 @@ else
$(error "This system's OS $(LOCAL_OS) isn't recognized/supported")
endif

ARCH := $(shell uname -m)
ARCH ?= $(shell uname -m)
LOCAL_ARCH := "amd64"
ifeq ($(ARCH),x86_64)
LOCAL_ARCH="amd64"
Expand All @@ -78,7 +79,7 @@ REGISTRY ?= "docker-na-public.artifactory.swg-devops.com/hyc-cloud-private-scrat
# Current Operator image name
OPERATOR_IMAGE_NAME ?= common-service-operator
# Current Operator bundle image name
BUNDLE_IMAGE_NAME ?= common-service-operator-bundle
BUNDLE_IMAGE_NAME ?= ibm-common-service-operator-bundle
# Current Operator image with registry
IMG ?= icr.io/cpopen/common-service-operator:$(LATEST_VERSION)

Expand Down Expand Up @@ -217,6 +218,34 @@ update-csv-image: # updates operator image in currently deployed Common Service

build-catalog: build-bundle-image build-catalog-source

.PHONY: catalog-render
catalog-render: ## Render an FBC locally from CATALOG_BASE_IMG.
mkdir -p catalog
opm render $(CATALOG_BASE_IMG) -o yaml > catalog/index.yml

.PHONY: bundle-render
bundle-render: ## Render the bundle contents into the local FBC index.
./common/scripts/bundle-render ibm-common-service-operator.v$(VERSION) $(QUAY_REGISTRY)/$(BUNDLE_IMAGE_NAME):$(VERSION)

.PHONY: bundle-push
bundle-push:
docker push $(QUAY_REGISTRY)/$(BUNDLE_IMAGE_NAME):$(VERSION)

.PHONY: catalog-validate
catalog-validate: ## Validate the FBC.
opm validate catalog

.PHONY: catalog-build
catalog-build: catalog-validate ## Build a catalog image.
test -s catalog.Dockerfile || opm generate dockerfile catalog
docker build . --platform linux/amd64 -f catalog.Dockerfile -t $(QUAY_REGISTRY)/$(IMG)-catalog-amd64:$(GIT_COMMIT_ID)
docker build . --platform linux/ppc64le -f catalog.Dockerfile -t $(QUAY_REGISTRY)/$(IMG)-catalog-ppc64le:$(GIT_COMMIT_ID)
docker build . --platform linux/s390x -f catalog.Dockerfile -t $(QUAY_REGISTRY)/$(IMG)-catalog-s390x:$(GIT_COMMIT_ID)

.PHONY: catalog-push
catalog-push: ## Push the catalog image to the registry.
@DOCKER_BUILDKIT=1 MAX_PULLING_RETRY=20 RETRY_INTERVAL=30 common/scripts/multiarch_image.sh $(REGISTRY) $(IMG)-catalog $(GIT_COMMIT_ID) $(VERSION) "false"

deploy-catalog: build-catalog
./common/scripts/update_catalogsource.sh $(OPERATOR_IMAGE_NAME) $(QUAY_REGISTRY)/$(OPERATOR_IMAGE_NAME)-catalog:$(VERSION)

Expand Down
33 changes: 33 additions & 0 deletions common/scripts/bundle-render
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

set -e -u -o pipefail

REPO_ROOT=""
if command -v realpath &>/dev/null
then
REPO_ROOT="$(realpath $(dirname $0)/../..)"
else
REPO_ROOT="$(dirname $0/../..)"
fi

export bundle_name="${1}"
export bundle_img="${2}"

rc=0
yq -e \
'select(.schema == "olm.bundle" and .name == env(bundle_name))' \
${REPO_ROOT}/catalog/index.yml &>/dev/null ||
rc=$?
# If the bundle is already present in the index, update the image reference used; otherwise, render from the image in
# the registry
if [[ $rc == 0 ]]; then
yq -i \
'with(select(.schema == "olm.bundle" and .name == env(bundle_name)); .image = env(bundle_img))' \
${REPO_ROOT}/catalog/index.yml ||
rc=$?
else
opm render ${bundle_img} \
--output=yaml \
>> ${REPO_ROOT}/catalog/index.yml
fi

11 changes: 10 additions & 1 deletion common/scripts/multiarch_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,28 @@ IMAGE_REPO=${1}
IMAGE_NAME=${2}
VERSION=${3-"$(git describe --exact-match 2> /dev/null || git describe --match=$(git rev-parse --short=8 HEAD) --always --dirty --abbrev=8)"}
RELEASE_VERSION=${4:-4.15.0}
IS_MANIFEST="${5:-true}"
MAX_PULLING_RETRY=${MAX_PULLING_RETRY-10}
RETRY_INTERVAL=${RETRY_INTERVAL-10}
# support other container tools, e.g. podman
CONTAINER_CLI=${CONTAINER_CLI:-docker}

inspect_cmd=()

if [[ "${IS_MANIFEST}" == "true" ]]
then
inspect_cmd+=( manifest inspect )
else
inspect_cmd+=( inspect )
fi
# Loop until the image for each single platform is ready in the docker registry.
# TODO: remove this if prow job support dependency.
for arch in ${ALL_PLATFORMS}
do
for i in $(seq 1 "${MAX_PULLING_RETRY}")
do
echo "Checking image '${IMAGE_REPO}'/'${IMAGE_NAME}'-'${arch}':'${VERSION}'..."
${CONTAINER_CLI} manifest inspect "${IMAGE_REPO}"/"${IMAGE_NAME}"-"${arch}":"${VERSION}" && break
${CONTAINER_CLI} "${inspect_cmd[@]}" "${IMAGE_REPO}"/"${IMAGE_NAME}"-"${arch}":"${VERSION}" && break
sleep "${RETRY_INTERVAL}"
if [ "${i}" -eq "${MAX_PULLING_RETRY}" ]; then
echo "Failed to found image '${IMAGE_REPO}'/'${IMAGE_NAME}'-'${arch}':'${VERSION}'!!!"
Expand Down