From 42344e30e7b473832dc12db3ef9a08989d7c3615 Mon Sep 17 00:00:00 2001 From: ashish Date: Thu, 11 Jul 2024 13:22:15 +0530 Subject: [PATCH] chore: update boilerplate Signed-off-by: ashish --- .ci-operator.yaml | 2 +- .github/dependabot.yml | 10 ------ OWNERS_ALIASES | 33 ++++++++++--------- boilerplate/_data/backing-image-tag | 2 +- boilerplate/_data/last-boilerplate-commit | 2 +- boilerplate/_lib/common.sh | 4 +-- .../Dockerfile.olm-registry | 5 ++- .../golang-osd-operator/OWNERS_ALIASES | 33 ++++++++++--------- .../app-sre-build-deploy.sh | 14 ++++++-- .../csv-generate/catalog-build.sh | 7 +++- .../csv-generate/catalog-publish.sh | 15 ++++++++- .../common-generate-operator-bundle.py | 9 +++++ .../csv-generate/csv-generate.mk | 22 +++++++++++++ .../csv-generate/csv-generate.sh | 30 ++++++++++++++++- .../openshift/golang-osd-operator/ensure.sh | 2 +- .../golang-osd-operator/golangci.yml | 7 ++++ .../openshift/golang-osd-operator/project.mk | 33 +++++++++++++++++++ .../golang-osd-operator/rvmo-bundle.sh | 8 +++-- .../openshift/golang-osd-operator/standard.mk | 18 ++++++---- build/Dockerfile | 2 +- build/Dockerfile.olm-registry | 5 ++- 21 files changed, 199 insertions(+), 64 deletions(-) diff --git a/.ci-operator.yaml b/.ci-operator.yaml index 433f62f5..9b90924e 100644 --- a/.ci-operator.yaml +++ b/.ci-operator.yaml @@ -1,4 +1,4 @@ build_root_image: name: boilerplate namespace: openshift - tag: image-v5.0.0 + tag: image-v5.0.1 diff --git a/.github/dependabot.yml b/.github/dependabot.yml index a7915fa2..004cb068 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -12,13 +12,3 @@ updates: # don't upgrade boilerplate via these means - dependency-name: "openshift4/ose-operator-registry" # don't upgrade ose-operator-registry via these means - - package-ecosystem: gomod - directory: "/" - schedule: - interval: "weekly" - labels: - - "area/dependency" - - "ok-to-test" - commit-message: - prefix: fix - include: scope diff --git a/OWNERS_ALIASES b/OWNERS_ALIASES index ecc0d0ad..9d966c85 100644 --- a/OWNERS_ALIASES +++ b/OWNERS_ALIASES @@ -5,12 +5,12 @@ aliases: srep-functional-team-aurora: - abyrne55 - - bdematte - - boranx + - AlexVulaj - dakotalongRH - lnguyen1401 - luis-falcon - rafael-azevedo + - reedcort srep-functional-team-fedramp: - tonytheleg - theautoroboto @@ -18,6 +18,8 @@ aliases: - katherinelc321 - robotmaxtron - rojasreinold + - hbhushan3 + - fsferraz-rh srep-functional-team-hulk: - a7vicky - rendhalver @@ -26,9 +28,11 @@ aliases: - weherdh - devppratik srep-functional-team-orange: + - bergmannf - bng0y - typeid - Makdaam + - mrWinston - Nikokolas3270 - ninabauer - RaphaelBut @@ -36,16 +40,18 @@ aliases: srep-functional-team-rocket: - aliceh - anispate - - bdmiller3 - clcollins - - mjlshen + - iamkirkbater + - Mhodesty + - nephomaniac - tnierman - - yithian srep-functional-team-security: - gsleeman - jaybeeunix - sam-nguyen7 - wshearn + - dem4gus + - npecka srep-functional-team-thor: - bmeng - MitaliBhalla @@ -53,19 +59,11 @@ aliases: - feichashao - Tafhim - samanthajayasinghe - srep-functional-team-v1alpha1: - - iamkirkbater - - AlexVulaj - - T0MASD - - bergmannf - - dkeohane - - reedcort - - mrWinston srep-functional-leads: - rafael-azevedo - iamkirkbater - - bng0y - - tonytheleg + - Nikokolas3270 + - theautoroboto - bmeng - mjlshen - sam-nguyen7 @@ -76,6 +74,11 @@ aliases: - fahlmant - dustman9000 - wanghaoran1988 + - bng0y + sre-group-leads: + - apahim + - maorfr + - rogbas srep-architects: - jewzaam - jharrington22 diff --git a/boilerplate/_data/backing-image-tag b/boilerplate/_data/backing-image-tag index 7f486aad..cb5b3ffc 100644 --- a/boilerplate/_data/backing-image-tag +++ b/boilerplate/_data/backing-image-tag @@ -1 +1 @@ -image-v5.0.0 +image-v5.0.1 diff --git a/boilerplate/_data/last-boilerplate-commit b/boilerplate/_data/last-boilerplate-commit index c59f0a5a..3d5d096c 100644 --- a/boilerplate/_data/last-boilerplate-commit +++ b/boilerplate/_data/last-boilerplate-commit @@ -1 +1 @@ -368331d7b41947c357275c024a610ae8652c1e53 +f9278d902be2c77e2980ad785e9dc9c585a49828 diff --git a/boilerplate/_lib/common.sh b/boilerplate/_lib/common.sh index 78703f61..26a10c4c 100755 --- a/boilerplate/_lib/common.sh +++ b/boilerplate/_lib/common.sh @@ -107,12 +107,12 @@ image_exists_in_repo() { fi echo "Image ${image_uri} exists with digest $digest." return 0 - elif [[ "$stderr" == *"manifest unknown"* ]]; then + elif [[ "$output" == *"manifest unknown"* || "$stderr" == *"manifest unknown"* ]]; then # We were able to talk to the repository, but the tag doesn't exist. # This is the normal "green field" case. echo "Image ${image_uri} does not exist in the repository." return 1 - elif [[ "$stderr" == *"was deleted or has expired"* ]]; then + elif [[ "$output" == *"manifest unknown"* || "$stderr" == *"was deleted or has expired"* ]]; then # This should be rare, but accounts for cases where we had to # manually delete an image. echo "Image ${image_uri} was deleted from the repository." diff --git a/boilerplate/openshift/golang-osd-operator/Dockerfile.olm-registry b/boilerplate/openshift/golang-osd-operator/Dockerfile.olm-registry index b1200088..396756db 100644 --- a/boilerplate/openshift/golang-osd-operator/Dockerfile.olm-registry +++ b/boilerplate/openshift/golang-osd-operator/Dockerfile.olm-registry @@ -1,4 +1,4 @@ -FROM registry.redhat.io/openshift4/ose-operator-registry:v4.12 AS builder +FROM registry.redhat.io/openshift4/ose-operator-registry:v4.14 AS builder ARG SAAS_OPERATOR_DIR COPY ${SAAS_OPERATOR_DIR} manifests RUN initializer --permissive @@ -20,3 +20,6 @@ COPY --from=builder /registry /registry EXPOSE 50051 CMD ["registry-server", "-t", "/tmp/terminate.log"] + +# Set the DC specific label for the location of the DC database in the image +LABEL operators.operatorframework.io.index.database.v1=/registry/bundles.db diff --git a/boilerplate/openshift/golang-osd-operator/OWNERS_ALIASES b/boilerplate/openshift/golang-osd-operator/OWNERS_ALIASES index ecc0d0ad..9d966c85 100644 --- a/boilerplate/openshift/golang-osd-operator/OWNERS_ALIASES +++ b/boilerplate/openshift/golang-osd-operator/OWNERS_ALIASES @@ -5,12 +5,12 @@ aliases: srep-functional-team-aurora: - abyrne55 - - bdematte - - boranx + - AlexVulaj - dakotalongRH - lnguyen1401 - luis-falcon - rafael-azevedo + - reedcort srep-functional-team-fedramp: - tonytheleg - theautoroboto @@ -18,6 +18,8 @@ aliases: - katherinelc321 - robotmaxtron - rojasreinold + - hbhushan3 + - fsferraz-rh srep-functional-team-hulk: - a7vicky - rendhalver @@ -26,9 +28,11 @@ aliases: - weherdh - devppratik srep-functional-team-orange: + - bergmannf - bng0y - typeid - Makdaam + - mrWinston - Nikokolas3270 - ninabauer - RaphaelBut @@ -36,16 +40,18 @@ aliases: srep-functional-team-rocket: - aliceh - anispate - - bdmiller3 - clcollins - - mjlshen + - iamkirkbater + - Mhodesty + - nephomaniac - tnierman - - yithian srep-functional-team-security: - gsleeman - jaybeeunix - sam-nguyen7 - wshearn + - dem4gus + - npecka srep-functional-team-thor: - bmeng - MitaliBhalla @@ -53,19 +59,11 @@ aliases: - feichashao - Tafhim - samanthajayasinghe - srep-functional-team-v1alpha1: - - iamkirkbater - - AlexVulaj - - T0MASD - - bergmannf - - dkeohane - - reedcort - - mrWinston srep-functional-leads: - rafael-azevedo - iamkirkbater - - bng0y - - tonytheleg + - Nikokolas3270 + - theautoroboto - bmeng - mjlshen - sam-nguyen7 @@ -76,6 +74,11 @@ aliases: - fahlmant - dustman9000 - wanghaoran1988 + - bng0y + sre-group-leads: + - apahim + - maorfr + - rogbas srep-architects: - jewzaam - jharrington22 diff --git a/boilerplate/openshift/golang-osd-operator/app-sre-build-deploy.sh b/boilerplate/openshift/golang-osd-operator/app-sre-build-deploy.sh index 0aa6dd79..a316a26f 100755 --- a/boilerplate/openshift/golang-osd-operator/app-sre-build-deploy.sh +++ b/boilerplate/openshift/golang-osd-operator/app-sre-build-deploy.sh @@ -60,10 +60,18 @@ while read dockerfile_path image_uri junk; do fi done <<< "$3" -for channel in staging production; do +declare -A hash +if [[ "${RELEASE_BRANCHED_BUILDS}" ]]; then + hash[stable]=v${OPERATOR_VERSION} +else + hash[staging]=staging-${CURRENT_COMMIT} + hash[production]=production-${CURRENT_COMMIT} +fi +for channel in "${!hash[@]}"; do + tag=${hash[$channel]} # If the catalog image already exists, short out - if image_exists_in_repo "${REGISTRY_IMAGE}:${channel}-${CURRENT_COMMIT}"; then - echo "Catalog image ${REGISTRY_IMAGE}:${channel}-${CURRENT_COMMIT} already " + if image_exists_in_repo "${REGISTRY_IMAGE}:${tag}"; then + echo "Catalog image ${REGISTRY_IMAGE}:${tag} already " echo "exists. Assuming this means the saas bundle work has also been done " echo "properly. Nothing to do!" else diff --git a/boilerplate/openshift/golang-osd-operator/csv-generate/catalog-build.sh b/boilerplate/openshift/golang-osd-operator/csv-generate/catalog-build.sh index 904ef767..c899879a 100755 --- a/boilerplate/openshift/golang-osd-operator/csv-generate/catalog-build.sh +++ b/boilerplate/openshift/golang-osd-operator/csv-generate/catalog-build.sh @@ -61,7 +61,12 @@ channels: currentCSV: ${operator_name}.v${OPERATOR_NEW_VERSION} EOF -${CONTAINER_ENGINE} build --pull -f "${DOCKERFILE_REGISTRY}" --build-arg "SAAS_OPERATOR_DIR=${SAAS_OPERATOR_DIR}" --tag "${registry_image}:${operator_channel}-latest" . +TAG="${operator_channel}-latest" +if [[ "${RELEASE_BRANCHED_BUILDS}" ]]; then + TAG="v${OPERATOR_NEW_VERSION}" +fi + +${CONTAINER_ENGINE} build --pull -f "${DOCKERFILE_REGISTRY}" --build-arg "SAAS_OPERATOR_DIR=${SAAS_OPERATOR_DIR}" --tag "${registry_image}:${TAG}" . if [ $? -ne 0 ] ; then echo "docker build failed, exiting..." diff --git a/boilerplate/openshift/golang-osd-operator/csv-generate/catalog-publish.sh b/boilerplate/openshift/golang-osd-operator/csv-generate/catalog-publish.sh index 16205295..1420378d 100755 --- a/boilerplate/openshift/golang-osd-operator/csv-generate/catalog-publish.sh +++ b/boilerplate/openshift/golang-osd-operator/csv-generate/catalog-publish.sh @@ -84,7 +84,7 @@ replaces ${OPERATOR_PREV_VERSION} removed versions: ${REMOVED_VERSIONS}" git commit -m "${MESSAGE}" -git push origin "${operator_channel}" +git push origin HEAD if [ $? -ne 0 ] ; then echo "git push failed, exiting..." @@ -95,6 +95,19 @@ popd if [ "$push_catalog" = true ] ; then # push image + if [[ "${RELEASE_BRANCHED_BUILDS}" ]]; then + skopeo copy --dest-creds "${QUAY_USER}:${QUAY_TOKEN}" \ + "${SRC_CONTAINER_TRANSPORT}:${registry_image}:v${OPERATOR_NEW_VERSION}" \ + "docker://${registry_image}:v${OPERATOR_NEW_VERSION}" + + if [ $? -ne 0 ] ; then + echo "skopeo push of ${registry_image}:v${OPERATOR_NEW_VERSION}-latest failed, exiting..." + exit 1 + fi + + exit 0 + fi + skopeo copy --dest-creds "${QUAY_USER}:${QUAY_TOKEN}" \ "${SRC_CONTAINER_TRANSPORT}:${registry_image}:${operator_channel}-latest" \ "docker://${registry_image}:${operator_channel}-latest" diff --git a/boilerplate/openshift/golang-osd-operator/csv-generate/common-generate-operator-bundle.py b/boilerplate/openshift/golang-osd-operator/csv-generate/common-generate-operator-bundle.py index e6b4a233..da70a06b 100755 --- a/boilerplate/openshift/golang-osd-operator/csv-generate/common-generate-operator-bundle.py +++ b/boilerplate/openshift/golang-osd-operator/csv-generate/common-generate-operator-bundle.py @@ -58,6 +58,15 @@ hasMultipleDeployments = False +# Verify that this is not creating a cycle. +if prev_version == full_version: + print( + "Previous version equals current version. " + "This would result in a cycle that can not be installed - aborting." + ) + sys.exit(1) + + class UnsupportedRegistryResourceKind(Exception): def __init__(self, kind, path): super().__init__( diff --git a/boilerplate/openshift/golang-osd-operator/csv-generate/csv-generate.mk b/boilerplate/openshift/golang-osd-operator/csv-generate/csv-generate.mk index a08868fc..bf4bb0ac 100644 --- a/boilerplate/openshift/golang-osd-operator/csv-generate/csv-generate.mk +++ b/boilerplate/openshift/golang-osd-operator/csv-generate/csv-generate.mk @@ -45,3 +45,25 @@ production-catalog-build-and-publish: @$(MAKE) -s production-csv-build --no-print-directory @$(MAKE) -s production-catalog-build --no-print-directory @$(MAKE) -s production-catalog-publish --no-print-directory + +.PHONY: stable-csv-build +stable-csv-build: + @${CONVENTION_DIR}/csv-generate/csv-generate.sh -o $(OPERATOR_NAME) -i $(OPERATOR_IMAGE) -V $(OPERATOR_VERSION) -c stable -H $(CURRENT_COMMIT) -n $(COMMIT_NUMBER) -s $(SUPPLEMENTARY_IMAGE) -e $(SKIP_RANGE_ENABLED) + +.PHONY: stable-catalog-build +stable-catalog-build: + @${CONVENTION_DIR}/csv-generate/catalog-build.sh -o $(OPERATOR_NAME) -c stable -r ${REGISTRY_IMAGE} + +.PHONY: stable-saas-bundle-push +stable-saas-bundle-push: + @${CONVENTION_DIR}/csv-generate/catalog-publish.sh -o $(OPERATOR_NAME) -c stable -H $(CURRENT_COMMIT) -n $(COMMIT_NUMBER) -r ${REGISTRY_IMAGE} + +.PHONY: stable-catalog-publish +stable-catalog-publish: + @${CONVENTION_DIR}/csv-generate/catalog-publish.sh -o $(OPERATOR_NAME) -c stable -H $(CURRENT_COMMIT) -n $(COMMIT_NUMBER) -p -r ${REGISTRY_IMAGE} + +.PHONY: stable-catalog-build-and-publish +stable-catalog-build-and-publish: + @$(MAKE) -s stable-csv-build --no-print-directory + @$(MAKE) -s stable-catalog-build --no-print-directory + @$(MAKE) -s stable-catalog-publish --no-print-directory diff --git a/boilerplate/openshift/golang-osd-operator/csv-generate/csv-generate.sh b/boilerplate/openshift/golang-osd-operator/csv-generate/csv-generate.sh index 5966a8db..3778ebef 100755 --- a/boilerplate/openshift/golang-osd-operator/csv-generate/csv-generate.sh +++ b/boilerplate/openshift/golang-osd-operator/csv-generate/csv-generate.sh @@ -80,7 +80,26 @@ SAAS_OPERATOR_DIR="saas-${operator_name}-bundle" BUNDLE_DIR="$SAAS_OPERATOR_DIR/${operator_name}/" rm -rf "$SAAS_OPERATOR_DIR" -git clone --branch "$operator_channel" ${GIT_PATH} "$SAAS_OPERATOR_DIR" +BRANCH="$operator_channel" +if [[ "${RELEASE_BRANCHED_BUILDS}" ]]; then + # operator version will be set to `X.Y.BUILD_NUMBER-commit sha`, this will + # be `release-X.Y` + BRANCH="release-${operator_version%.*}" +fi + +if [[ "${RELEASE_BRANCHED_BUILDS}" ]]; then + git clone ${GIT_PATH} "$SAAS_OPERATOR_DIR" + pushd "${SAAS_OPERATOR_DIR}" + # if branch doesn't exist, checkout a new branch based on main/master + if git ls-remote --exit-code --heads "${GIT_PATH}" "${BRANCH}"; then + git checkout "${BRANCH}" + else + git checkout -b "${BRANCH}" + fi + popd +else + git clone --branch "$operator_channel" ${GIT_PATH} "$SAAS_OPERATOR_DIR" +fi # If this is a brand new SaaS setup, then set up accordingly if [[ ! -d "${BUNDLE_DIR}" ]]; then @@ -165,6 +184,15 @@ OPERATOR_PREV_VERSION=$(ls "$BUNDLE_DIR" | sort -t . -k 3 -g | tail -n 1) OPERATOR_NEW_VERSION="${operator_version}" OUTPUT_DIR=${BUNDLE_DIR} +VERSION_DIR="${OUTPUT_DIR}/${OPERATOR_NEW_VERSION}" + +# Check if the VERSION_DIR already exists and is not empty - if so skip building +# anything, as only timestamps would be changed. +if [[ -d "${VERSION_DIR}" && -n $(ls -A "${VERSION_DIR}") ]]; then + echo "Output directory for bundle already exists and is not empty: ${VERSION_DIR}. Skipping bundle creation." + exit 0 +fi + # If setting up a new SaaS repo, there is no previous version when building a bundle # Optionally pass it to the bundle generator in that case. if [[ -z "${OPERATOR_PREV_VERSION}" ]]; then diff --git a/boilerplate/openshift/golang-osd-operator/ensure.sh b/boilerplate/openshift/golang-osd-operator/ensure.sh index ee747ee4..5e51f810 100755 --- a/boilerplate/openshift/golang-osd-operator/ensure.sh +++ b/boilerplate/openshift/golang-osd-operator/ensure.sh @@ -5,7 +5,7 @@ set -eo pipefail REPO_ROOT=$(git rev-parse --show-toplevel) source $REPO_ROOT/boilerplate/_lib/common.sh -GOLANGCI_LINT_VERSION="1.54.2" +GOLANGCI_LINT_VERSION="1.59.1" OPM_VERSION="v1.23.2" GRPCURL_VERSION="1.7.0" DEPENDENCY=${1:-} diff --git a/boilerplate/openshift/golang-osd-operator/golangci.yml b/boilerplate/openshift/golang-osd-operator/golangci.yml index 4cd695e3..b489f3ba 100644 --- a/boilerplate/openshift/golang-osd-operator/golangci.yml +++ b/boilerplate/openshift/golang-osd-operator/golangci.yml @@ -21,6 +21,13 @@ linters: - gosimple - govet - ineffassign + - misspell - staticcheck - typecheck - unused + +linters-settings: + misspell: + extra-words: + - typo: "openshit" + correction: "OpenShift" diff --git a/boilerplate/openshift/golang-osd-operator/project.mk b/boilerplate/openshift/golang-osd-operator/project.mk index e146a08d..1b9b5028 100644 --- a/boilerplate/openshift/golang-osd-operator/project.mk +++ b/boilerplate/openshift/golang-osd-operator/project.mk @@ -16,5 +16,38 @@ EnableOLMSkipRange?=$(shell sed -n 's/.*EnableOLMSkipRange .*"\([^"]*\)".*/\1/p' VERSION_MAJOR?=0 VERSION_MINOR?=1 +ifdef RELEASE_BRANCHED_BUILDS + # Make sure all called shell scripts know what's up + export RELEASE_BRANCHED_BUILDS + + # RELEASE_BRANCH from env vars takes precedence; if not set, try to figure it out + RELEASE_BRANCH:=${RELEASE_BRANCH} + ifneq ($(RELEASE_BRANCH),) + # Sanity check, just to be nice + RELEASE_BRANCH_TEST := $(shell echo ${RELEASE_BRANCH} | grep -E '^release-[0-9]+\.[0-9]+$$') + ifeq ($(RELEASE_BRANCH_TEST),) + $(warning Provided RELEASE_BRANCH doesn't conform to "release-X.Y" pattern; you sure you didn't make a mistake?) + endif + endif + + ifeq ($(RELEASE_BRANCH),) + # Check git repo's branch first + RELEASE_BRANCH := $(shell git rev-parse --abbrev-ref HEAD | grep -E '^release-[0-9]+\.[0-9]+$$') + endif + + ifeq ($(RELEASE_BRANCH),) + # Try to parse it out of Jenkins' JOB_NAME + RELEASE_BRANCH := $(shell echo ${JOB_NAME} | grep -E --only-matching 'release-[0-9]+\.[0-9]+') + endif + + ifeq ($(RELEASE_BRANCH),) + $(error RELEASE_BRANCHED_BUILDS is set, but couldn't detect a release branch and RELEASE_BRANCH is not set; giving up) + else + SEMVER := $(subst release-,,$(subst ., ,$(RELEASE_BRANCH))) + VERSION_MAJOR := $(firstword $(SEMVER)) + VERSION_MINOR := $(lastword $(SEMVER)) + endif +endif + REGISTRY_USER?=$(QUAY_USER) REGISTRY_TOKEN?=$(QUAY_TOKEN) diff --git a/boilerplate/openshift/golang-osd-operator/rvmo-bundle.sh b/boilerplate/openshift/golang-osd-operator/rvmo-bundle.sh index b2e9109b..f49d8c66 100644 --- a/boilerplate/openshift/golang-osd-operator/rvmo-bundle.sh +++ b/boilerplate/openshift/golang-osd-operator/rvmo-bundle.sh @@ -2,12 +2,16 @@ set -e -REPOSITORY=${REPOSITORY:-"git@github.com:openshift/managed-release-bundle.git"} -BRANCH=${BRANCH:-main} +REPOSITORY=${REPOSITORY:-"https://github.com/openshift/managed-release-bundle-osd.git"} +CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD|egrep '^main$|^release-[0-9]+\.[0-9]+$'|cat) +RVMO_BRANCH=${CURRENT_BRANCH:-main} +# You can override any branch detection by setting RELEASE_BRANCH +BRANCH=${RELEASE_BRANCH:-$RVMO_BRANCH} DELETE_TEMP_DIR=${DELETE_TEMP_DIR:-true} TMPD=$(mktemp -d --suffix -rvmo-bundle) [[ "${DELETE_TEMP_DIR}" == "true" ]] && trap 'rm -rf ${TMPD}' EXIT cd "${TMPD}" +echo "Cloning RVMO from ${REPOSITORY}:${BRANCH}" git clone --single-branch -b "${BRANCH}" "${REPOSITORY}" . bash hack/update-operator-release.sh diff --git a/boilerplate/openshift/golang-osd-operator/standard.mk b/boilerplate/openshift/golang-osd-operator/standard.mk index 17362068..6f888dc1 100644 --- a/boilerplate/openshift/golang-osd-operator/standard.mk +++ b/boilerplate/openshift/golang-osd-operator/standard.mk @@ -21,17 +21,17 @@ endif # invocation; otherwise it could collide across jenkins jobs. We'll use # a .docker folder relative to pwd (the repo root). CONTAINER_ENGINE_CONFIG_DIR = .docker -# But docker and podman use different options to configure it :eyeroll: -# ==> Podman uses --authfile=PATH *after* the `login` subcommand; but -# also accepts REGISTRY_AUTH_FILE from the env. See -# https://www.mankier.com/1/podman-login#Options---authfile=path export REGISTRY_AUTH_FILE = ${CONTAINER_ENGINE_CONFIG_DIR}/config.json + # If this configuration file doesn't exist, podman will error out. So # we'll create it if it doesn't exist. ifeq (,$(wildcard $(REGISTRY_AUTH_FILE))) $(shell mkdir -p $(CONTAINER_ENGINE_CONFIG_DIR)) -$(shell echo '{}' > $(REGISTRY_AUTH_FILE)) +# Copy the node container auth file so that we get access to the registries the +# parent node has access to +$(shell cp /var/lib/jenkins/.docker/config.json $(REGISTRY_AUTH_FILE)) endif + # ==> Docker uses --config=PATH *before* (any) subcommand; so we'll glue # that to the CONTAINER_ENGINE variable itself. (NOTE: I tried half a # dozen other ways to do this. This was the least ugly one that actually @@ -43,7 +43,7 @@ endif # Generate version and tag information from inputs COMMIT_NUMBER=$(shell git rev-list `git rev-list --parents HEAD | grep -E "^[a-f0-9]{40}$$"`..HEAD --count) CURRENT_COMMIT=$(shell git rev-parse --short=7 HEAD) -OPERATOR_VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(COMMIT_NUMBER)-$(CURRENT_COMMIT) +OPERATOR_VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(COMMIT_NUMBER)-g$(CURRENT_COMMIT) OPERATOR_IMAGE=$(IMAGE_REGISTRY)/$(IMAGE_REPOSITORY)/$(IMAGE_NAME) OPERATOR_IMAGE_TAG=v$(OPERATOR_VERSION) @@ -52,6 +52,7 @@ OPERATOR_IMAGE_URI=${IMG} OPERATOR_IMAGE_URI_LATEST=$(IMAGE_REGISTRY)/$(IMAGE_REPOSITORY)/$(IMAGE_NAME):latest OPERATOR_DOCKERFILE ?=build/Dockerfile REGISTRY_IMAGE=$(IMAGE_REGISTRY)/$(IMAGE_REPOSITORY)/$(IMAGE_NAME)-registry +OPERATOR_REPO_NAME=$(shell git config --get remote.origin.url | sed 's,.*/,,; s/\.git$$//') ifeq ($(SUPPLEMENTARY_IMAGE_NAME),) # We need SUPPLEMENTARY_IMAGE to be defined for csv-generate.mk @@ -323,6 +324,7 @@ coverage: # TODO: Boilerplate this script. .PHONY: build-push build-push: + OPERATOR_VERSION="${OPERATOR_VERSION}" \ ${CONVENTION_DIR}/app-sre-build-deploy.sh ${REGISTRY_IMAGE} ${CURRENT_COMMIT} "$$IMAGES_TO_BUILD" .PHONY: opm-build-push @@ -383,8 +385,10 @@ container-coverage: .PHONY: rvmo-bundle rvmo-bundle: + RELEASE_BRANCH=$(RELEASE_BRANCH) \ + REPO_NAME=$(OPERATOR_REPO_NAME) \ OPERATOR_NAME=$(OPERATOR_NAME) \ OPERATOR_VERSION=$(OPERATOR_VERSION) \ OPERATOR_OLM_REGISTRY_IMAGE=$(REGISTRY_IMAGE) \ - TEMPLATE_FILE=$(abspath hack/olm-registry/olm-artifacts-template.yaml) \ + TEMPLATE_DIR=$(abspath hack/release-bundle) \ bash ${CONVENTION_DIR}/rvmo-bundle.sh diff --git a/build/Dockerfile b/build/Dockerfile index 3328f718..ca9609fa 100644 --- a/build/Dockerfile +++ b/build/Dockerfile @@ -1,4 +1,4 @@ -FROM quay.io/app-sre/boilerplate:image-v5.0.0 AS builder +FROM quay.io/app-sre/boilerplate:image-v5.0.1 AS builder WORKDIR /workdir diff --git a/build/Dockerfile.olm-registry b/build/Dockerfile.olm-registry index d44e1439..d78c3420 100644 --- a/build/Dockerfile.olm-registry +++ b/build/Dockerfile.olm-registry @@ -1,4 +1,4 @@ -FROM registry.redhat.io/openshift4/ose-operator-registry:v4.12 AS builder +FROM registry.redhat.io/openshift4/ose-operator-registry:v4.14 AS builder ARG SAAS_OPERATOR_DIR COPY ${SAAS_OPERATOR_DIR} manifests RUN initializer --permissive @@ -20,3 +20,6 @@ COPY --from=builder /registry /registry EXPOSE 50051 CMD ["registry-server", "-t", "/tmp/terminate.log"] + +# Set the DC specific label for the location of the DC database in the image +LABEL operators.operatorframework.io.index.database.v1=/registry/bundles.db