Skip to content

Commit 244795e

Browse files
authored
Merge pull request #345 from tremes/boilerplate-update
Bump up boilerplate version
2 parents fca8912 + d1cce7b commit 244795e

20 files changed

+171
-28
lines changed

.ci-operator.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
build_root_image:
22
name: boilerplate
33
namespace: openshift
4-
tag: image-v5.0.0
4+
tag: image-v5.0.1

OWNERS_ALIASES

+4-2
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ aliases:
4242
- anispate
4343
- clcollins
4444
- iamkirkbater
45+
- Mhodesty
46+
- nephomaniac
4547
- tnierman
46-
- yithian
4748
srep-functional-team-security:
4849
- gsleeman
4950
- jaybeeunix
5051
- sam-nguyen7
5152
- wshearn
52-
- SamuelSidakwo
53+
- dem4gus
54+
- npecka
5355
srep-functional-team-thor:
5456
- bmeng
5557
- MitaliBhalla

boilerplate/_data/backing-image-tag

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
image-v5.0.0
1+
image-v5.0.1
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
368331d7b41947c357275c024a610ae8652c1e53
1+
5be0e418987099c08f75632eea3b2fe382b626ed

boilerplate/_lib/common.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ image_exists_in_repo() {
107107
fi
108108
echo "Image ${image_uri} exists with digest $digest."
109109
return 0
110-
elif [[ "$stderr" == *"manifest unknown"* ]]; then
110+
elif [[ "$output" == *"manifest unknown"* || "$stderr" == *"manifest unknown"* ]]; then
111111
# We were able to talk to the repository, but the tag doesn't exist.
112112
# This is the normal "green field" case.
113113
echo "Image ${image_uri} does not exist in the repository."
114114
return 1
115-
elif [[ "$stderr" == *"was deleted or has expired"* ]]; then
115+
elif [[ "$output" == *"manifest unknown"* || "$stderr" == *"was deleted or has expired"* ]]; then
116116
# This should be rare, but accounts for cases where we had to
117117
# manually delete an image.
118118
echo "Image ${image_uri} was deleted from the repository."

boilerplate/openshift/golang-osd-operator/Dockerfile.olm-registry

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM registry.redhat.io/openshift4/ose-operator-registry:v4.12 AS builder
1+
FROM registry.redhat.io/openshift4/ose-operator-registry:v4.14 AS builder
22
ARG SAAS_OPERATOR_DIR
33
COPY ${SAAS_OPERATOR_DIR} manifests
44
RUN initializer --permissive
@@ -20,3 +20,6 @@ COPY --from=builder /registry /registry
2020
EXPOSE 50051
2121

2222
CMD ["registry-server", "-t", "/tmp/terminate.log"]
23+
24+
# Set the DC specific label for the location of the DC database in the image
25+
LABEL operators.operatorframework.io.index.database.v1=/registry/bundles.db

boilerplate/openshift/golang-osd-operator/OWNERS_ALIASES

+4-2
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ aliases:
4242
- anispate
4343
- clcollins
4444
- iamkirkbater
45+
- Mhodesty
46+
- nephomaniac
4547
- tnierman
46-
- yithian
4748
srep-functional-team-security:
4849
- gsleeman
4950
- jaybeeunix
5051
- sam-nguyen7
5152
- wshearn
52-
- SamuelSidakwo
53+
- dem4gus
54+
- npecka
5355
srep-functional-team-thor:
5456
- bmeng
5557
- MitaliBhalla

boilerplate/openshift/golang-osd-operator/app-sre-build-deploy.sh

+11-3
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,18 @@ while read dockerfile_path image_uri junk; do
6060
fi
6161
done <<< "$3"
6262

63-
for channel in staging production; do
63+
declare -A hash
64+
if [[ "${RELEASE_BRANCHED_BUILDS}" ]]; then
65+
hash[stable]=v${OPERATOR_VERSION}
66+
else
67+
hash[staging]=staging-${CURRENT_COMMIT}
68+
hash[production]=production-${CURRENT_COMMIT}
69+
fi
70+
for channel in "${!hash[@]}"; do
71+
tag=${hash[$channel]}
6472
# If the catalog image already exists, short out
65-
if image_exists_in_repo "${REGISTRY_IMAGE}:${channel}-${CURRENT_COMMIT}"; then
66-
echo "Catalog image ${REGISTRY_IMAGE}:${channel}-${CURRENT_COMMIT} already "
73+
if image_exists_in_repo "${REGISTRY_IMAGE}:${tag}"; then
74+
echo "Catalog image ${REGISTRY_IMAGE}:${tag} already "
6775
echo "exists. Assuming this means the saas bundle work has also been done "
6876
echo "properly. Nothing to do!"
6977
else

boilerplate/openshift/golang-osd-operator/csv-generate/catalog-build.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ channels:
6161
currentCSV: ${operator_name}.v${OPERATOR_NEW_VERSION}
6262
EOF
6363

64-
${CONTAINER_ENGINE} build --pull -f "${DOCKERFILE_REGISTRY}" --build-arg "SAAS_OPERATOR_DIR=${SAAS_OPERATOR_DIR}" --tag "${registry_image}:${operator_channel}-latest" .
64+
TAG="${operator_channel}-latest"
65+
if [[ "${RELEASE_BRANCHED_BUILDS}" ]]; then
66+
TAG="v${OPERATOR_NEW_VERSION}"
67+
fi
68+
69+
${CONTAINER_ENGINE} build --pull -f "${DOCKERFILE_REGISTRY}" --build-arg "SAAS_OPERATOR_DIR=${SAAS_OPERATOR_DIR}" --tag "${registry_image}:${TAG}" .
6570

6671
if [ $? -ne 0 ] ; then
6772
echo "docker build failed, exiting..."

boilerplate/openshift/golang-osd-operator/csv-generate/catalog-publish.sh

+14-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ replaces ${OPERATOR_PREV_VERSION}
8484
removed versions: ${REMOVED_VERSIONS}"
8585

8686
git commit -m "${MESSAGE}"
87-
git push origin "${operator_channel}"
87+
git push origin HEAD
8888

8989
if [ $? -ne 0 ] ; then
9090
echo "git push failed, exiting..."
@@ -95,6 +95,19 @@ popd
9595

9696
if [ "$push_catalog" = true ] ; then
9797
# push image
98+
if [[ "${RELEASE_BRANCHED_BUILDS}" ]]; then
99+
skopeo copy --dest-creds "${QUAY_USER}:${QUAY_TOKEN}" \
100+
"${SRC_CONTAINER_TRANSPORT}:${registry_image}:v${OPERATOR_NEW_VERSION}" \
101+
"docker://${registry_image}:v${OPERATOR_NEW_VERSION}"
102+
103+
if [ $? -ne 0 ] ; then
104+
echo "skopeo push of ${registry_image}:v${OPERATOR_NEW_VERSION}-latest failed, exiting..."
105+
exit 1
106+
fi
107+
108+
exit 0
109+
fi
110+
98111
skopeo copy --dest-creds "${QUAY_USER}:${QUAY_TOKEN}" \
99112
"${SRC_CONTAINER_TRANSPORT}:${registry_image}:${operator_channel}-latest" \
100113
"docker://${registry_image}:${operator_channel}-latest"

boilerplate/openshift/golang-osd-operator/csv-generate/common-generate-operator-bundle.py

+9
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@
5858

5959
hasMultipleDeployments = False
6060

61+
# Verify that this is not creating a cycle.
62+
if prev_version == full_version:
63+
print(
64+
"Previous version equals current version. "
65+
"This would result in a cycle that can not be installed - aborting."
66+
)
67+
sys.exit(1)
68+
69+
6170
class UnsupportedRegistryResourceKind(Exception):
6271
def __init__(self, kind, path):
6372
super().__init__(

boilerplate/openshift/golang-osd-operator/csv-generate/csv-generate.mk

+22
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,25 @@ production-catalog-build-and-publish:
4545
@$(MAKE) -s production-csv-build --no-print-directory
4646
@$(MAKE) -s production-catalog-build --no-print-directory
4747
@$(MAKE) -s production-catalog-publish --no-print-directory
48+
49+
.PHONY: stable-csv-build
50+
stable-csv-build:
51+
@${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)
52+
53+
.PHONY: stable-catalog-build
54+
stable-catalog-build:
55+
@${CONVENTION_DIR}/csv-generate/catalog-build.sh -o $(OPERATOR_NAME) -c stable -r ${REGISTRY_IMAGE}
56+
57+
.PHONY: stable-saas-bundle-push
58+
stable-saas-bundle-push:
59+
@${CONVENTION_DIR}/csv-generate/catalog-publish.sh -o $(OPERATOR_NAME) -c stable -H $(CURRENT_COMMIT) -n $(COMMIT_NUMBER) -r ${REGISTRY_IMAGE}
60+
61+
.PHONY: stable-catalog-publish
62+
stable-catalog-publish:
63+
@${CONVENTION_DIR}/csv-generate/catalog-publish.sh -o $(OPERATOR_NAME) -c stable -H $(CURRENT_COMMIT) -n $(COMMIT_NUMBER) -p -r ${REGISTRY_IMAGE}
64+
65+
.PHONY: stable-catalog-build-and-publish
66+
stable-catalog-build-and-publish:
67+
@$(MAKE) -s stable-csv-build --no-print-directory
68+
@$(MAKE) -s stable-catalog-build --no-print-directory
69+
@$(MAKE) -s stable-catalog-publish --no-print-directory

boilerplate/openshift/golang-osd-operator/csv-generate/csv-generate.sh

+29-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,26 @@ SAAS_OPERATOR_DIR="saas-${operator_name}-bundle"
8080
BUNDLE_DIR="$SAAS_OPERATOR_DIR/${operator_name}/"
8181

8282
rm -rf "$SAAS_OPERATOR_DIR"
83-
git clone --branch "$operator_channel" ${GIT_PATH} "$SAAS_OPERATOR_DIR"
83+
BRANCH="$operator_channel"
84+
if [[ "${RELEASE_BRANCHED_BUILDS}" ]]; then
85+
# operator version will be set to `X.Y.BUILD_NUMBER-commit sha`, this will
86+
# be `release-X.Y`
87+
BRANCH="release-${operator_version%.*}"
88+
fi
89+
90+
if [[ "${RELEASE_BRANCHED_BUILDS}" ]]; then
91+
git clone ${GIT_PATH} "$SAAS_OPERATOR_DIR"
92+
pushd "${SAAS_OPERATOR_DIR}"
93+
# if branch doesn't exist, checkout a new branch based on main/master
94+
if git ls-remote --exit-code --heads "${GIT_PATH}" "${BRANCH}"; then
95+
git checkout "${BRANCH}"
96+
else
97+
git checkout -b "${BRANCH}"
98+
fi
99+
popd
100+
else
101+
git clone --branch "$operator_channel" ${GIT_PATH} "$SAAS_OPERATOR_DIR"
102+
fi
84103

85104
# If this is a brand new SaaS setup, then set up accordingly
86105
if [[ ! -d "${BUNDLE_DIR}" ]]; then
@@ -165,6 +184,15 @@ OPERATOR_PREV_VERSION=$(ls "$BUNDLE_DIR" | sort -t . -k 3 -g | tail -n 1)
165184
OPERATOR_NEW_VERSION="${operator_version}"
166185
OUTPUT_DIR=${BUNDLE_DIR}
167186

187+
VERSION_DIR="${OUTPUT_DIR}/${OPERATOR_NEW_VERSION}"
188+
189+
# Check if the VERSION_DIR already exists and is not empty - if so skip building
190+
# anything, as only timestamps would be changed.
191+
if [[ -d "${VERSION_DIR}" && -n $(ls -A "${VERSION_DIR}") ]]; then
192+
echo "Output directory for bundle already exists and is not empty: ${VERSION_DIR}. Skipping bundle creation."
193+
exit 0
194+
fi
195+
168196
# If setting up a new SaaS repo, there is no previous version when building a bundle
169197
# Optionally pass it to the bundle generator in that case.
170198
if [[ -z "${OPERATOR_PREV_VERSION}" ]]; then

boilerplate/openshift/golang-osd-operator/ensure.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -eo pipefail
55
REPO_ROOT=$(git rev-parse --show-toplevel)
66
source $REPO_ROOT/boilerplate/_lib/common.sh
77

8-
GOLANGCI_LINT_VERSION="1.54.2"
8+
GOLANGCI_LINT_VERSION="1.59.1"
99
OPM_VERSION="v1.23.2"
1010
GRPCURL_VERSION="1.7.0"
1111
DEPENDENCY=${1:-}

boilerplate/openshift/golang-osd-operator/golangci.yml

+7
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ linters:
2121
- gosimple
2222
- govet
2323
- ineffassign
24+
- misspell
2425
- staticcheck
2526
- typecheck
2627
- unused
28+
29+
linters-settings:
30+
misspell:
31+
extra-words:
32+
- typo: "openshit"
33+
correction: "OpenShift"

boilerplate/openshift/golang-osd-operator/project.mk

+33
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,38 @@ EnableOLMSkipRange?=$(shell sed -n 's/.*EnableOLMSkipRange .*"\([^"]*\)".*/\1/p'
1616
VERSION_MAJOR?=0
1717
VERSION_MINOR?=1
1818

19+
ifdef RELEASE_BRANCHED_BUILDS
20+
# Make sure all called shell scripts know what's up
21+
export RELEASE_BRANCHED_BUILDS
22+
23+
# RELEASE_BRANCH from env vars takes precedence; if not set, try to figure it out
24+
RELEASE_BRANCH:=${RELEASE_BRANCH}
25+
ifneq ($(RELEASE_BRANCH),)
26+
# Sanity check, just to be nice
27+
RELEASE_BRANCH_TEST := $(shell echo ${RELEASE_BRANCH} | grep -E '^release-[0-9]+\.[0-9]+$$')
28+
ifeq ($(RELEASE_BRANCH_TEST),)
29+
$(warning Provided RELEASE_BRANCH doesn't conform to "release-X.Y" pattern; you sure you didn't make a mistake?)
30+
endif
31+
endif
32+
33+
ifeq ($(RELEASE_BRANCH),)
34+
# Check git repo's branch first
35+
RELEASE_BRANCH := $(shell git rev-parse --abbrev-ref HEAD | grep -E '^release-[0-9]+\.[0-9]+$$')
36+
endif
37+
38+
ifeq ($(RELEASE_BRANCH),)
39+
# Try to parse it out of Jenkins' JOB_NAME
40+
RELEASE_BRANCH := $(shell echo ${JOB_NAME} | grep -E --only-matching 'release-[0-9]+\.[0-9]+')
41+
endif
42+
43+
ifeq ($(RELEASE_BRANCH),)
44+
$(error RELEASE_BRANCHED_BUILDS is set, but couldn't detect a release branch and RELEASE_BRANCH is not set; giving up)
45+
else
46+
SEMVER := $(subst release-,,$(subst ., ,$(RELEASE_BRANCH)))
47+
VERSION_MAJOR := $(firstword $(SEMVER))
48+
VERSION_MINOR := $(lastword $(SEMVER))
49+
endif
50+
endif
51+
1952
REGISTRY_USER?=$(QUAY_USER)
2053
REGISTRY_TOKEN?=$(QUAY_TOKEN)

boilerplate/openshift/golang-osd-operator/rvmo-bundle.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22

33
set -e
44

5-
REPOSITORY=${REPOSITORY:-"[email protected]:openshift/managed-release-bundle.git"}
6-
BRANCH=${BRANCH:-main}
5+
REPOSITORY=${REPOSITORY:-"https://github.com/openshift/managed-release-bundle-osd.git"}
6+
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD|egrep '^main$|^release-[0-9]+\.[0-9]+$'|cat)
7+
RVMO_BRANCH=${CURRENT_BRANCH:-main}
8+
# You can override any branch detection by setting RELEASE_BRANCH
9+
BRANCH=${RELEASE_BRANCH:-$RVMO_BRANCH}
710
DELETE_TEMP_DIR=${DELETE_TEMP_DIR:-true}
811
TMPD=$(mktemp -d --suffix -rvmo-bundle)
912
[[ "${DELETE_TEMP_DIR}" == "true" ]] && trap 'rm -rf ${TMPD}' EXIT
1013

1114
cd "${TMPD}"
15+
echo "Cloning RVMO from ${REPOSITORY}:${BRANCH}"
1216
git clone --single-branch -b "${BRANCH}" "${REPOSITORY}" .
1317
bash hack/update-operator-release.sh

boilerplate/openshift/golang-osd-operator/standard.mk

+11-7
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ endif
2121
# invocation; otherwise it could collide across jenkins jobs. We'll use
2222
# a .docker folder relative to pwd (the repo root).
2323
CONTAINER_ENGINE_CONFIG_DIR = .docker
24-
# But docker and podman use different options to configure it :eyeroll:
25-
# ==> Podman uses --authfile=PATH *after* the `login` subcommand; but
26-
# also accepts REGISTRY_AUTH_FILE from the env. See
27-
# https://www.mankier.com/1/podman-login#Options---authfile=path
2824
export REGISTRY_AUTH_FILE = ${CONTAINER_ENGINE_CONFIG_DIR}/config.json
25+
2926
# If this configuration file doesn't exist, podman will error out. So
3027
# we'll create it if it doesn't exist.
3128
ifeq (,$(wildcard $(REGISTRY_AUTH_FILE)))
3229
$(shell mkdir -p $(CONTAINER_ENGINE_CONFIG_DIR))
33-
$(shell echo '{}' > $(REGISTRY_AUTH_FILE))
30+
# Copy the node container auth file so that we get access to the registries the
31+
# parent node has access to
32+
$(shell cp /var/lib/jenkins/.docker/config.json $(REGISTRY_AUTH_FILE))
3433
endif
34+
3535
# ==> Docker uses --config=PATH *before* (any) subcommand; so we'll glue
3636
# that to the CONTAINER_ENGINE variable itself. (NOTE: I tried half a
3737
# dozen other ways to do this. This was the least ugly one that actually
@@ -43,7 +43,7 @@ endif
4343
# Generate version and tag information from inputs
4444
COMMIT_NUMBER=$(shell git rev-list `git rev-list --parents HEAD | grep -E "^[a-f0-9]{40}$$"`..HEAD --count)
4545
CURRENT_COMMIT=$(shell git rev-parse --short=7 HEAD)
46-
OPERATOR_VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(COMMIT_NUMBER)-$(CURRENT_COMMIT)
46+
OPERATOR_VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(COMMIT_NUMBER)-g$(CURRENT_COMMIT)
4747

4848
OPERATOR_IMAGE=$(IMAGE_REGISTRY)/$(IMAGE_REPOSITORY)/$(IMAGE_NAME)
4949
OPERATOR_IMAGE_TAG=v$(OPERATOR_VERSION)
@@ -52,6 +52,7 @@ OPERATOR_IMAGE_URI=${IMG}
5252
OPERATOR_IMAGE_URI_LATEST=$(IMAGE_REGISTRY)/$(IMAGE_REPOSITORY)/$(IMAGE_NAME):latest
5353
OPERATOR_DOCKERFILE ?=build/Dockerfile
5454
REGISTRY_IMAGE=$(IMAGE_REGISTRY)/$(IMAGE_REPOSITORY)/$(IMAGE_NAME)-registry
55+
OPERATOR_REPO_NAME=$(shell git config --get remote.origin.url | sed 's,.*/,,; s/\.git$$//')
5556

5657
ifeq ($(SUPPLEMENTARY_IMAGE_NAME),)
5758
# We need SUPPLEMENTARY_IMAGE to be defined for csv-generate.mk
@@ -323,6 +324,7 @@ coverage:
323324
# TODO: Boilerplate this script.
324325
.PHONY: build-push
325326
build-push:
327+
OPERATOR_VERSION="${OPERATOR_VERSION}" \
326328
${CONVENTION_DIR}/app-sre-build-deploy.sh ${REGISTRY_IMAGE} ${CURRENT_COMMIT} "$$IMAGES_TO_BUILD"
327329

328330
.PHONY: opm-build-push
@@ -383,8 +385,10 @@ container-coverage:
383385

384386
.PHONY: rvmo-bundle
385387
rvmo-bundle:
388+
RELEASE_BRANCH=$(RELEASE_BRANCH) \
389+
REPO_NAME=$(OPERATOR_REPO_NAME) \
386390
OPERATOR_NAME=$(OPERATOR_NAME) \
387391
OPERATOR_VERSION=$(OPERATOR_VERSION) \
388392
OPERATOR_OLM_REGISTRY_IMAGE=$(REGISTRY_IMAGE) \
389-
TEMPLATE_FILE=$(abspath hack/olm-registry/olm-artifacts-template.yaml) \
393+
TEMPLATE_DIR=$(abspath hack/release-bundle) \
390394
bash ${CONVENTION_DIR}/rvmo-bundle.sh

build/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM quay.io/app-sre/boilerplate:image-v5.0.0 AS builder
1+
FROM quay.io/app-sre/boilerplate:image-v5.0.1 AS builder
22

33
RUN mkdir -p /workdir
44
COPY . /workdir

build/Dockerfile.olm-registry

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM registry.redhat.io/openshift4/ose-operator-registry:v4.12 AS builder
1+
FROM registry.redhat.io/openshift4/ose-operator-registry:v4.14 AS builder
22
ARG SAAS_OPERATOR_DIR
33
COPY ${SAAS_OPERATOR_DIR} manifests
44
RUN initializer --permissive
@@ -20,3 +20,6 @@ COPY --from=builder /registry /registry
2020
EXPOSE 50051
2121

2222
CMD ["registry-server", "-t", "/tmp/terminate.log"]
23+
24+
# Set the DC specific label for the location of the DC database in the image
25+
LABEL operators.operatorframework.io.index.database.v1=/registry/bundles.db

0 commit comments

Comments
 (0)