Skip to content

Commit

Permalink
chore: update boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajpantuso committed Dec 4, 2024
1 parent 1fe4b31 commit 00ae9ac
Show file tree
Hide file tree
Showing 24 changed files with 149 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .ci-operator.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build_root_image:
name: boilerplate
namespace: openshift
tag: image-v5.0.1
tag: image-v6.0.1
13 changes: 7 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ repos:

- repo: local
hooks:
- id: goimports
name: goimports
entry: hack/ensure-and-run-goimports.sh
language: system
types: [go]
require_serial: true # mage does not like multiple parallel compiles
# Temporaril
# - id: goimports
# name: goimports
# entry: hack/ensure-and-run-goimports.sh
# language: system
# types: [go]
# require_serial: true # mage does not like multiple parallel compiles

- id: go-mod-tidy
name: go-mod-tidy
Expand Down
34 changes: 22 additions & 12 deletions OWNERS_ALIASES
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
aliases:
srep-functional-team-aurora:
- abyrne55
- AlexVulaj
- dakotalongRH
- lnguyen1401
- joshbranham
- luis-falcon
- rafael-azevedo
- reedcort
srep-functional-team-fedramp:
- tonytheleg
Expand All @@ -25,8 +23,12 @@ aliases:
- rendhalver
- ravitri
- shitaljante
- weherdh
- devppratik
- Tafhim
- tkong-redhat
- TheUndeadKing
- vaidehi411
- chamalabey
srep-functional-team-orange:
- bergmannf
- bng0y
Expand All @@ -36,40 +38,48 @@ aliases:
- Nikokolas3270
- ninabauer
- RaphaelBut
- Tessg22
srep-functional-team-rocket:
- aliceh
- anispate
- clcollins
- iamkirkbater
- Mhodesty
- nephomaniac
- tnierman
srep-functional-team-security:
- gsleeman
- jaybeeunix
- sam-nguyen7
- wshearn
- dem4gus
- npecka
- pshickeydev
- casey-williams-rh
srep-functional-team-thor:
- bmeng
- MitaliBhalla
- hectorakemp
- feichashao
- Tafhim
- samanthajayasinghe
- xiaoyu74
- Dee-6777
- Tessg22
srep-infra-cicd:
- mmazur
- mrsantamaria
- ritmun
- jbpratt
- yiqinzhang
srep-functional-leads:
- rafael-azevedo
- iamkirkbater
- abyrne55
- clcollins
- Nikokolas3270
- theautoroboto
- bmeng
- mjlshen
- sam-nguyen7
- ravitri
- mmazur
srep-team-leads:
- NautiluX
- rafael-azevedo
- iamkirkbater
- rogbas
- fahlmant
- dustman9000
Expand Down
2 changes: 1 addition & 1 deletion boilerplate/_data/backing-image-tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
image-v5.0.1
image-v6.0.1
2 changes: 1 addition & 1 deletion boilerplate/_data/last-boilerplate-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f9278d902be2c77e2980ad785e9dc9c585a49828
462b0bc5a5c55acfd02f330a165c1da27bc45c91
13 changes: 11 additions & 2 deletions boilerplate/_lib/boilerplate-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env bash

set -e
if [ "$BOILERPLATE_SET_X" ]; then
set -x
fi

REPO_ROOT=$(git rev-parse --show-toplevel)
source $REPO_ROOT/boilerplate/_lib/common.sh
Expand Down Expand Up @@ -53,8 +56,14 @@ elif grep -q '^ M boilerplate/_data/last-boilerplate-commit$' $git_status; then
bp_compare_url="https://github.com/openshift/boilerplate/compare/$bp_commit_change"
# Generate the commit history for this range. This will go in the commit message.
(
$BOILERPLATE_GIT_CLONE $bp_clone
cd $bp_clone
if [[ -z "${BOILERPLATE_IN_CI}" ]]; then
git clone "${BOILERPLATE_GIT_REPO}" "${bp_clone}"
else
# HACK: We can't get around safe.directory in CI, so just leverage cp instead of git
cp -r /go/src/github.com/openshift/boilerplate/* "${bp_clone}"
cp -r /go/src/github.com/openshift/boilerplate/.git "${bp_clone}"
fi
cd "${bp_clone}"
# Matches promote.sh
git log --no-merges --pretty=format:'commit: %H%nauthor: %an%n%s%n%n%b%n%n' $bp_commit_change > $bp_log
)
Expand Down
12 changes: 8 additions & 4 deletions boilerplate/_lib/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ image_exists_in_repo() {

local skopeo_stderr=$(mktemp)

if ! command -v skopeo &>/dev/null; then
echo "Failed to find the skopeo binary. If you are on Mac: brew install skopeo." >&2
exit 1
fi

output=$(skopeo inspect docker://${image_uri} 2>$skopeo_stderr)
rc=$?
# So we can delete the temp file right away...
Expand Down Expand Up @@ -177,10 +182,9 @@ fi
if [ -z "$BOILERPLATE_GIT_REPO" ]; then
export BOILERPLATE_GIT_REPO=https://github.com/openshift/boilerplate.git
fi
if [ -z "$BOILERPLATE_GIT_CLONE" ]; then
export BOILERPLATE_GIT_CLONE="git clone $BOILERPLATE_GIT_REPO"
fi

# Base image repo url
IMAGE_REPO=quay.io/redhat-services-prod/openshift
# The namespace of the ImageStream by which prow will import the image.
IMAGE_NAMESPACE=openshift
IMAGE_NAME=boilerplate
Expand All @@ -197,4 +201,4 @@ if [[ -z "$LATEST_IMAGE_TAG" ]]; then
fi
fi
# The public image location
IMAGE_PULL_PATH=${IMAGE_PULL_PATH:-quay.io/app-sre/$IMAGE_NAME:$LATEST_IMAGE_TAG}
IMAGE_PULL_PATH=${IMAGE_PULL_PATH:-$IMAGE_REPO/$IMAGE_NAME:$LATEST_IMAGE_TAG}
2 changes: 1 addition & 1 deletion boilerplate/_lib/freeze-check
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ git reset --hard FETCH_HEAD
# close a security hole whereby the latter is overridden.
echo "Running update"
cd $REPO_ROOT
BOILERPLATE_GIT_CLONE="git clone $TMPD" boilerplate/update
BOILERPLATE_GIT_REPO="${TMPD}" boilerplate/update

# Okay, if anything has changed, that's bad.
if [[ $(git status --porcelain -- ':!build/Dockerfile*' | wc -l) -ne 0 ]]; then
Expand Down
34 changes: 22 additions & 12 deletions boilerplate/openshift/golang-osd-operator/OWNERS_ALIASES
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
aliases:
srep-functional-team-aurora:
- abyrne55
- AlexVulaj
- dakotalongRH
- lnguyen1401
- joshbranham
- luis-falcon
- rafael-azevedo
- reedcort
srep-functional-team-fedramp:
- tonytheleg
Expand All @@ -25,8 +23,12 @@ aliases:
- rendhalver
- ravitri
- shitaljante
- weherdh
- devppratik
- Tafhim
- tkong-redhat
- TheUndeadKing
- vaidehi411
- chamalabey
srep-functional-team-orange:
- bergmannf
- bng0y
Expand All @@ -36,40 +38,48 @@ aliases:
- Nikokolas3270
- ninabauer
- RaphaelBut
- Tessg22
srep-functional-team-rocket:
- aliceh
- anispate
- clcollins
- iamkirkbater
- Mhodesty
- nephomaniac
- tnierman
srep-functional-team-security:
- gsleeman
- jaybeeunix
- sam-nguyen7
- wshearn
- dem4gus
- npecka
- pshickeydev
- casey-williams-rh
srep-functional-team-thor:
- bmeng
- MitaliBhalla
- hectorakemp
- feichashao
- Tafhim
- samanthajayasinghe
- xiaoyu74
- Dee-6777
- Tessg22
srep-infra-cicd:
- mmazur
- mrsantamaria
- ritmun
- jbpratt
- yiqinzhang
srep-functional-leads:
- rafael-azevedo
- iamkirkbater
- abyrne55
- clcollins
- Nikokolas3270
- theautoroboto
- bmeng
- mjlshen
- sam-nguyen7
- ravitri
- mmazur
srep-team-leads:
- NautiluX
- rafael-azevedo
- iamkirkbater
- rogbas
- fahlmant
- dustman9000
Expand Down
16 changes: 13 additions & 3 deletions boilerplate/openshift/golang-osd-operator/build-opm-catalog.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ OLM_BUNDLE_VERSIONS_REPO_BRANCH=${OLM_BUNDLE_VERSIONS_REPO_BRANCH:-master}

# Global vars
REPO_ROOT=$(git rev-parse --show-toplevel)
PYTHON=.venv/bin/python3

function log() {
local to_log=${1}
Expand Down Expand Up @@ -226,6 +227,14 @@ function build_opm_catalog() {
from_arg="--from-index $OLM_CATALOG_IMAGE:$prev_commit"
fi

# check if the previous catalog image is available
if [ $(${image_builder} pull ${OLM_CATALOG_IMAGE}:${prev_commit} &> /dev/null;echo $?) -gt 0 ]; then
# remove the first character
prev_commit=${prev_commit:1}
from_arg="--from-index $OLM_CATALOG_IMAGE:$prev_commit"
fi

log "Index argument is $from_arg"
log "Creating catalog image $catalog_image_current_commit using opm"
# shellcheck disable=SC2086
$opm_local_executable index add --bundles "$bundle_image_current_commit" \
Expand All @@ -243,7 +252,7 @@ function check_opm_catalog() {
log "Checking that catalog we have built returns the correct version $OPERATOR_VERSION"

local free_port
free_port=$(python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()')
free_port=$(${PYTHON} -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()')

log "Running $catalog_image_current_commit and exposing $free_port"
local catalog_container_id
Expand Down Expand Up @@ -337,9 +346,10 @@ function main() {
return 0
fi

local bundle_image_current_commit="$OLM_BUNDLE_IMAGE:$CURRENT_COMMIT"
# the commit needs a 'g' prefix for the bundle image
local bundle_image_current_commit="${OLM_BUNDLE_IMAGE}:g${CURRENT_COMMIT}"
local bundle_image_latest="$OLM_BUNDLE_IMAGE:latest"
local catalog_image_current_commit="$OLM_CATALOG_IMAGE:$CURRENT_COMMIT"
local catalog_image_current_commit="${OLM_CATALOG_IMAGE}:${CURRENT_COMMIT}"
local catalog_image_latest="$OLM_CATALOG_IMAGE:latest"

bundle_image_current_commit=$(build_opm_bundle "${temp_dir}" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ BUNDLE_DIR="${SAAS_OPERATOR_DIR}/${operator_name}"
OPERATOR_NEW_VERSION=$(ls "${BUNDLE_DIR}" | sort -t . -k 3 -g | tail -n 1)
OPERATOR_PREV_VERSION=$(ls "${BUNDLE_DIR}" | sort -t . -k 3 -g | tail -n 2 | head -n 1)

if [[ "$OPERATOR_NEW_VERSION" == "$OPERATOR_PREV_VERSION" ]]; then
echo "New version and previous version are identical. Exiting."
exit 1
fi

# Get container engine
CONTAINER_ENGINE=$(command -v podman || command -v docker || true)
[[ -n "$CONTAINER_ENGINE" ]] || echo "WARNING: Couldn't find a container engine. Assuming you already in a container, running unit tests." >&2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ if [[ -z "$SKIP_SAAS_FILE_CHECKS" ]]; then

if [[ "$delete" == false ]]; then
short_hash=$(echo "$version" | cut -d- -f2)


# before comparing the short_hash to the deployment hash, remove the leading g added in https://issues.redhat.com/browse/OSD-13681
# short_hash should be 7 char long without the leading g.
[ ${#short_hash} -gt 7 ] && short_hash=${short_hash:1:7}

if [[ "$DEPLOYED_HASH" == "${short_hash}"* ]]; then
delete=true
fi
Expand Down
4 changes: 0 additions & 4 deletions boilerplate/openshift/golang-osd-operator/golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,3 @@ linters-settings:
extra-words:
- typo: "openshit"
correction: "OpenShift"
ignore-words:
- reconcilation
- reconcilations
- Reconcilation
6 changes: 6 additions & 0 deletions boilerplate/openshift/golang-osd-operator/prow-config
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ resources:
cpu: 100m
memory: 200Mi
tests:
- as: e2e-binary-build-success
commands: |
make e2e-harness-build
container:
from: src
run_if_changed: ^(osde2e/.*|go\.mod|go\.sum)$
- as: coverage
commands: |
export CODECOV_TOKEN=\$(cat /tmp/secret/CODECOV_TOKEN)
Expand Down
2 changes: 1 addition & 1 deletion boilerplate/openshift/golang-osd-operator/standard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ build-push:
${CONVENTION_DIR}/app-sre-build-deploy.sh ${REGISTRY_IMAGE} ${CURRENT_COMMIT} "$$IMAGES_TO_BUILD"

.PHONY: opm-build-push
opm-build-push: docker-push
opm-build-push: python-venv docker-push
OLM_BUNDLE_IMAGE="${OLM_BUNDLE_IMAGE}" \
OLM_CATALOG_IMAGE="${OLM_CATALOG_IMAGE}" \
CONTAINER_ENGINE="${CONTAINER_ENGINE}" \
Expand Down
19 changes: 19 additions & 0 deletions boilerplate/openshift/golang-osd-operator/update
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@ if [[ -f ${REPO_ROOT}/.gitignore ]]; then
${SED?} -i "/Dockerfile.olm-registry/d" ${REPO_ROOT}/.gitignore
fi

OPERATOR_NAME=$(sed -n 's/.*OperatorName .*"\([^"]*\)".*/\1/p' "${REPO_ROOT}/config/config.go")

if [[ ! -f ${REPO_ROOT}/config/metadata/additional-labels.txt ]]; then
mkdir -p ${REPO_ROOT}/config/metadata
cat >${REPO_ROOT}/config/metadata/additional-labels.txt <<EOF
LABEL com.redhat.component="openshift-${OPERATOR_NAME}" \
io.k8s.description="..." \
description="..." \
distribution-scope="public" \
name="openshift/${OPERATOR_NAME}" \
url="https://github.com/openshift/${OPERATOR_NAME}" \
vendor="Red Hat, Inc." \
release="v0.0.0" \
version="v0.0.0"
EOF
fi

IMAGE_PULL_PATH="quay.io/redhat-services-prod/openshift/boilerplate:${LATEST_IMAGE_TAG}"

# Update Dockerfile builder image
DOCKERFILES=$(ls -1 $REPO_ROOT/build/Dockerfile*)
for file in $DOCKERFILES; do
Expand Down
Loading

0 comments on commit 00ae9ac

Please sign in to comment.