diff --git a/.ci-operator.yaml b/.ci-operator.yaml index 9b90924e..5d936014 100644 --- a/.ci-operator.yaml +++ b/.ci-operator.yaml @@ -1,4 +1,4 @@ build_root_image: name: boilerplate namespace: openshift - tag: image-v5.0.1 + tag: image-v6.0.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cd5cb418..9d93d6fb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/OWNERS_ALIASES b/OWNERS_ALIASES index 9d966c85..32f1ca31 100644 --- a/OWNERS_ALIASES +++ b/OWNERS_ALIASES @@ -5,11 +5,9 @@ aliases: srep-functional-team-aurora: - abyrne55 - - AlexVulaj - dakotalongRH - - lnguyen1401 + - joshbranham - luis-falcon - - rafael-azevedo - reedcort srep-functional-team-fedramp: - tonytheleg @@ -25,8 +23,12 @@ aliases: - rendhalver - ravitri - shitaljante - - weherdh - devppratik + - Tafhim + - tkong-redhat + - TheUndeadKing + - vaidehi411 + - chamalabey srep-functional-team-orange: - bergmannf - bng0y @@ -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 diff --git a/boilerplate/_data/backing-image-tag b/boilerplate/_data/backing-image-tag index cb5b3ffc..10efb639 100644 --- a/boilerplate/_data/backing-image-tag +++ b/boilerplate/_data/backing-image-tag @@ -1 +1 @@ -image-v5.0.1 +image-v6.0.1 diff --git a/boilerplate/_data/last-boilerplate-commit b/boilerplate/_data/last-boilerplate-commit index 3d5d096c..68ea59fd 100644 --- a/boilerplate/_data/last-boilerplate-commit +++ b/boilerplate/_data/last-boilerplate-commit @@ -1 +1 @@ -f9278d902be2c77e2980ad785e9dc9c585a49828 +462b0bc5a5c55acfd02f330a165c1da27bc45c91 diff --git a/boilerplate/_lib/boilerplate-commit b/boilerplate/_lib/boilerplate-commit index 074f74f4..5ec2a77b 100755 --- a/boilerplate/_lib/boilerplate-commit +++ b/boilerplate/_lib/boilerplate-commit @@ -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 @@ -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 ) diff --git a/boilerplate/_lib/common.sh b/boilerplate/_lib/common.sh index 26a10c4c..a3298af5 100755 --- a/boilerplate/_lib/common.sh +++ b/boilerplate/_lib/common.sh @@ -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... @@ -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 @@ -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} diff --git a/boilerplate/_lib/freeze-check b/boilerplate/_lib/freeze-check index 080629f5..4109ac9a 100755 --- a/boilerplate/_lib/freeze-check +++ b/boilerplate/_lib/freeze-check @@ -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 diff --git a/boilerplate/openshift/golang-osd-operator/OWNERS_ALIASES b/boilerplate/openshift/golang-osd-operator/OWNERS_ALIASES index 9d966c85..32f1ca31 100644 --- a/boilerplate/openshift/golang-osd-operator/OWNERS_ALIASES +++ b/boilerplate/openshift/golang-osd-operator/OWNERS_ALIASES @@ -5,11 +5,9 @@ aliases: srep-functional-team-aurora: - abyrne55 - - AlexVulaj - dakotalongRH - - lnguyen1401 + - joshbranham - luis-falcon - - rafael-azevedo - reedcort srep-functional-team-fedramp: - tonytheleg @@ -25,8 +23,12 @@ aliases: - rendhalver - ravitri - shitaljante - - weherdh - devppratik + - Tafhim + - tkong-redhat + - TheUndeadKing + - vaidehi411 + - chamalabey srep-functional-team-orange: - bergmannf - bng0y @@ -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 diff --git a/boilerplate/openshift/golang-osd-operator/build-opm-catalog.sh b/boilerplate/openshift/golang-osd-operator/build-opm-catalog.sh index 3bb8328c..3e5ef6dd 100755 --- a/boilerplate/openshift/golang-osd-operator/build-opm-catalog.sh +++ b/boilerplate/openshift/golang-osd-operator/build-opm-catalog.sh @@ -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} @@ -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" \ @@ -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 @@ -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}" \ 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 1420378d..eb1c7547 100755 --- a/boilerplate/openshift/golang-osd-operator/csv-generate/catalog-publish.sh +++ b/boilerplate/openshift/golang-osd-operator/csv-generate/catalog-publish.sh @@ -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 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 3778ebef..1b69bed4 100755 --- a/boilerplate/openshift/golang-osd-operator/csv-generate/csv-generate.sh +++ b/boilerplate/openshift/golang-osd-operator/csv-generate/csv-generate.sh @@ -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 diff --git a/boilerplate/openshift/golang-osd-operator/golangci.yml b/boilerplate/openshift/golang-osd-operator/golangci.yml index b171fbca..b489f3ba 100644 --- a/boilerplate/openshift/golang-osd-operator/golangci.yml +++ b/boilerplate/openshift/golang-osd-operator/golangci.yml @@ -31,7 +31,3 @@ linters-settings: extra-words: - typo: "openshit" correction: "OpenShift" - ignore-words: - - reconcilation - - reconcilations - - Reconcilation diff --git a/boilerplate/openshift/golang-osd-operator/prow-config b/boilerplate/openshift/golang-osd-operator/prow-config index 9ff8f46f..4b145490 100755 --- a/boilerplate/openshift/golang-osd-operator/prow-config +++ b/boilerplate/openshift/golang-osd-operator/prow-config @@ -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) diff --git a/boilerplate/openshift/golang-osd-operator/standard.mk b/boilerplate/openshift/golang-osd-operator/standard.mk index 6f888dc1..67a77b66 100644 --- a/boilerplate/openshift/golang-osd-operator/standard.mk +++ b/boilerplate/openshift/golang-osd-operator/standard.mk @@ -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}" \ diff --git a/boilerplate/openshift/golang-osd-operator/update b/boilerplate/openshift/golang-osd-operator/update index f64a6f27..1accc646 100755 --- a/boilerplate/openshift/golang-osd-operator/update +++ b/boilerplate/openshift/golang-osd-operator/update @@ -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 <