Skip to content

Commit

Permalink
Clean up, rearrange stuff in the csv generation scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Malay Kumar Parida <[email protected]>
  • Loading branch information
malayparida2000 committed Sep 27, 2023
1 parent b659cd2 commit 608b945
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 61 deletions.
2 changes: 2 additions & 0 deletions hack/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ GO_LINT_IMG="${GO_LINT_IMG:-${GO_LINT_IMG_LOCATION}:${GO_LINT_IMG_TAG}}"
# Current DEV version of the CSV
DEFAULT_CSV_VERSION="4.14.0"
CSV_VERSION="${CSV_VERSION:-${DEFAULT_CSV_VERSION}}"
REPLACES_VERSION="${REPLACES_VERSION:-}"
SKIP_RANGE=">=0.0.1 <${CSV_VERSION}"
VERSION="${VERSION:-${CSV_VERSION}}"
LDFLAGS="-X github.com/red-hat-storage/ocs-operator/v4/version.Version=${CSV_VERSION}"

Expand Down
2 changes: 0 additions & 2 deletions hack/docker-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ if [ -z "$IMAGE_BUILD_CMD" ]; then
echo -e '\033[1;31m' "podman or docker not found on system" '\033[0m'
exit 1
fi

IMAGE_RUN_CMD="${IMAGE_RUN_CMD:-${IMAGE_BUILD_CMD} run --rm -it}"
21 changes: 11 additions & 10 deletions hack/generate-latest-csv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,29 @@ set -e

source hack/common.sh

export SKIP_MINIMUM="0.0.1"
export SKIP_RANGE=">=${SKIP_MINIMUM} <${CSV_VERSION}"

# Current dependency images our DEV CSV are pinned to
export OCS_IMAGE=${OCS_IMAGE:-${OPERATOR_FULL_IMAGE_NAME}}
export OCS_METRICS_EXPORTER_IMAGE=${OCS_METRICS_EXPORTER_IMAGE:-${METRICS_EXPORTER_FULL_IMAGE_NAME}}
export ROOK_IMAGE=${ROOK_IMAGE:-${LATEST_ROOK_IMAGE}}
export CEPH_IMAGE=${CEPH_IMAGE:-${LATEST_CEPH_IMAGE}}
export NOOBAA_CORE_IMAGE=${NOOBAA_CORE_IMAGE:-${LATEST_NOOBAA_CORE_IMAGE}}
export NOOBAA_DB_IMAGE=${NOOBAA_DB_IMAGE:-${LATEST_NOOBAA_DB_IMAGE}}
export CEPH_IMAGE=${CEPH_IMAGE:-${LATEST_CEPH_IMAGE}}
export OCS_IMAGE=${OCS_IMAGE:-${OPERATOR_FULL_IMAGE_NAME}}
export OCS_METRICS_EXPORTER_IMAGE=${OCS_METRICS_EXPORTER_IMAGE:-${METRICS_EXPORTER_FULL_IMAGE_NAME}}
export OCS_MUST_GATHER_IMAGE=${OCS_MUST_GATHER_IMAGE:-${LATEST_MUST_GATHER_IMAGE}}
export ROOK_CSIADDONS_IMAGE=${ROOK_CSIADDONS_IMAGE:-${LATEST_ROOK_CSIADDONS_IMAGE}}
export OCS_MUST_GATHER_IMAGE=${OCS_MUST_GATHER_IMAGE:-${LATEST_MUST_GATHER_IMAGE}}

echo "=== Generating DEV CSV with the following vars ==="
echo -e "\tCSV_VERSION=$CSV_VERSION"
echo -e "\tREPLACES_VERSION=$REPLACES_VERSION"
echo -e "\tSKIP_RANGE=$SKIP_RANGE"
echo -e "\tOCS_IMAGE=$OCS_IMAGE"
echo -e "\tOCS_METRICS_EXPORTER_IMAGE=$OCS_METRICS_EXPORTER_IMAGE"
echo -e "\tROOK_IMAGE=$ROOK_IMAGE"
echo -e "\tCEPH_IMAGE=$CEPH_IMAGE"
echo -e "\tNOOBAA_CORE_IMAGE=$NOOBAA_CORE_IMAGE"
echo -e "\tNOOBAA_DB_IMAGE=$NOOBAA_DB_IMAGE"
echo -e "\tOCS_IMAGE=$OCS_IMAGE"
echo -e "\tOCS_METRICS_EXPORTER_IMAGE=$OCS_METRICS_EXPORTER_IMAGE"
echo -e "\tOCS_MUST_GATHER_IMAGE=$OCS_MUST_GATHER_IMAGE"
echo -e "\tROOK_CSIADDONS_IMAGE=$ROOK_CSIADDONS_IMAGE"
echo -e "\tOCS_MUST_GATHER_IMAGE=$OCS_MUST_GATHER_IMAGE"

hack/source-manifests.sh

hack/generate-unified-csv.sh
44 changes: 9 additions & 35 deletions hack/generate-unified-csv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,24 @@ CSV_MERGER="tools/csv-merger/csv-merger"

(cd tools/csv-merger/ && go build -ldflags="${LDFLAGS}")

function help_txt() {
echo "Environment Variables"
echo " OCS_IMAGE: (required) The ocs operator container image to integrate with"
echo " OCS_METRICS_EXPORTER_IMAGE: (required) The ocs metrics exporter container image to integrate with"
echo " NOOBAA_CORE_IMAGE: (required) The noobaa core container image to integrate with"
echo " NOOBAA_DB_IMAGE: (required) DB container image that is used by noobaa"
echo " ROOK_IMAGE: (required) The rook operator container image to integrate with"
echo " CEPH_IMAGE: (required) The ceph daemon container image to be deployed with storage clusters"
echo " CSV_VERSION: (required) The ocs-operator csv version that will be generated"
echo " REPLACES_CSV_VERSION (optional) The ocs-operator csv version this new csv will be updating"
echo " SKIP_RANGE (optional) The skip range value set for this csv"
echo " ROOK_CSI_CEPH_IMAGE (optional) Sets custom image env var on the rook deployment spec"
echo " ROOK_CSI_REGISTRAR_IMAGE (optional) Sets custom image env var on the rook deployment spec"
echo " ROOK_CSI_RESIZER_IMAGE (optional) Sets custom image env var on the rook deployment spec"
echo " ROOK_CSI_PROVISIONER_IMAGE (optional) Sets custom image env var on the rook deployment spec"
echo " ROOK_CSI_SNAPSHOTTER_IMAGE (optional) Sets custom image env var on the rook deployment spec"
echo " ROOK_CSI_ATTACHER_IMAGE (optional) Sets custom image env var on the rook deployment spec"
echo ""
echo "Example usage:"
echo " ROOK_IMAGE=<image> CSV_VERSION=<version> $0"
}

# check required env vars
if [ -z "$NOOBAA_CORE_IMAGE" ] || [ -z "$NOOBAA_DB_IMAGE" ] || \
[ -z "$ROOK_IMAGE" ] || [ -z "$CSV_VERSION" ] || [ -z "$OCS_IMAGE" ] || [ -z "$OCS_METRICS_EXPORTER_IMAGE" ] || \
[ -z "$CEPH_IMAGE" ]; then
help_txt
echo ""
if [ -z "$CSV_VERSION" ] || [ -z "$OCS_IMAGE" ] || [ -z "$OCS_METRICS_EXPORTER_IMAGE" ] || \
[ -z "$ROOK_IMAGE" ] || [ -z "$CEPH_IMAGE" ] || [ -z "$NOOBAA_CORE_IMAGE" ] || [ -z "$NOOBAA_DB_IMAGE" ] \
; then
echo "ERROR: Missing required environment variables"
exit 1
fi

hack/source-manifests.sh

# Merge component-level operators into ocs CSV
$CSV_MERGER \
--csv-version="$CSV_VERSION" \
--replaces-csv-version="$REPLACES_CSV_VERSION" \
--skip-range="$SKIP_RANGE" \
--rook-csv-filepath=$ROOK_CSV \
--ocs-csv-filepath=$OCS_CSV \
--ocs-image="$OCS_IMAGE" \
--ocs-metrics-exporter-image="$OCS_METRICS_EXPORTER_IMAGE" \
--rook-image="$ROOK_IMAGE" \
--ceph-image="$CEPH_IMAGE" \
--rook-csiaddons-image="$ROOK_CSIADDONS_IMAGE" \
--rook-csi-ceph-image="$ROOK_CSI_CEPH_IMAGE" \
--rook-csi-registrar-image="$ROOK_CSI_REGISTRAR_IMAGE" \
--rook-csi-resizer-image="$ROOK_CSI_RESIZER_IMAGE" \
Expand All @@ -59,11 +34,10 @@ $CSV_MERGER \
--rook-csi-attacher-image="$ROOK_CSI_ATTACHER_IMAGE" \
--noobaa-core-image="$NOOBAA_CORE_IMAGE" \
--noobaa-db-image="$NOOBAA_DB_IMAGE" \
--ocs-image="$OCS_IMAGE" \
--ocs-metrics-exporter-image="$OCS_METRICS_EXPORTER_IMAGE" \
--ocs-must-gather-image="$OCS_MUST_GATHER_IMAGE" \
--rook-csv-filepath=$ROOK_CSV \
--ocs-csv-filepath=$OCS_CSV \
--crds-directory="$CRDS_DIR" \
--manifests-directory=$EXTRA_MANIFESTS_DIR \
--olm-bundle-directory="$BUNDLE_MANIFESTS_DIR" \
--timestamp="$TIMESTAMP" \
--rook-csiaddons-image="$ROOK_CSIADDONS_IMAGE"
--timestamp="$TIMESTAMP"
15 changes: 2 additions & 13 deletions hack/source-manifests.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
#!/usr/bin/env bash

# example: ROOK_IMAGE=build-e858f56d/ceph-amd64:latest OCS_IMAGE=placeholder CSV_VERSION=1.1.1 hack/generate-manifests.sh

set -e

source hack/common.sh

function help_txt() {
echo "Environment Variables"
echo " ROOK_IMAGE: (required) The rook operator container image to integrate with"
echo ""
echo "Example usage:"
echo " ROOK_IMAGE=<image> $0"
}
source hack/docker-common.sh

# check required env vars
if [ -z "$ROOK_IMAGE" ]; then
help_txt
echo ""
if [ -z "$CSV_VERSION" ] || [ -z "$OCS_IMAGE" ] || [ -z "$ROOK_IMAGE" ]; then
echo "ERROR: Missing required environment variables"
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion hack/verify-operator-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ set -e

source hack/ensure-operator-sdk.sh

${OPERATOR_SDK} bundle validate "$(dirname $OCS_FINAL_DIR)" --verbose
${OPERATOR_SDK} bundle validate "$(dirname "$OCS_FINAL_DIR")" --verbose

0 comments on commit 608b945

Please sign in to comment.