|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -o errexit |
| 4 | +set -o nounset |
| 5 | +set -o pipefail |
| 6 | + |
| 7 | +SCRIPT_DIR="$( |
| 8 | + cd "$(dirname "$0")" >/dev/null |
| 9 | + pwd |
| 10 | +)" |
| 11 | + |
| 12 | +PROJECT_DIR="$( |
| 13 | + cd "$SCRIPT_DIR/.." >/dev/null |
| 14 | + pwd |
| 15 | +)" |
| 16 | + |
| 17 | +usage() { |
| 18 | + echo " |
| 19 | +Usage: |
| 20 | + ${0##*/} [options] |
| 21 | +
|
| 22 | +Optional arguments: |
| 23 | + -p, --product $PRODUCT |
| 24 | + The product on which to activate the pre-release subscription. |
| 25 | + Can be specified multiple times. |
| 26 | + -d, --debug |
| 27 | + Activate tracing/debug mode. |
| 28 | + -h, --help |
| 29 | + Display this message. |
| 30 | +
|
| 31 | +Example: |
| 32 | + ${0##*/} |
| 33 | +" >&2 |
| 34 | +} |
| 35 | + |
| 36 | +parse_args() { |
| 37 | + PRODUCT_LIST=() |
| 38 | + while [[ $# -gt 0 ]]; do |
| 39 | + case $1 in |
| 40 | + -p|--product) |
| 41 | + case $2 in |
| 42 | + developerHub|dh|rhdh) |
| 43 | + PRODUCT_LIST+=( "rhdh" ) |
| 44 | + ;; |
| 45 | + gitops|pipelines) |
| 46 | + PRODUCT_LIST+=( "$2" ) |
| 47 | + ;; |
| 48 | + *) |
| 49 | + echo "[ERROR] Unknown product: $1" |
| 50 | + usage |
| 51 | + ;; |
| 52 | + esac |
| 53 | + shift |
| 54 | + ;; |
| 55 | + -d | --debug) |
| 56 | + set -x |
| 57 | + DEBUG="--debug" |
| 58 | + export DEBUG |
| 59 | + ;; |
| 60 | + -h | --help) |
| 61 | + usage |
| 62 | + exit 0 |
| 63 | + ;; |
| 64 | + *) |
| 65 | + echo "[ERROR] Unknown argument: $1" |
| 66 | + usage |
| 67 | + exit 1 |
| 68 | + ;; |
| 69 | + esac |
| 70 | + shift |
| 71 | + done |
| 72 | +} |
| 73 | + |
| 74 | +init() { |
| 75 | + SHARED_DIR="$(mktemp -d)" |
| 76 | + cd $SHARED_DIR |
| 77 | + export SHARED_DIR |
| 78 | + trap cleanup EXIT |
| 79 | +} |
| 80 | + |
| 81 | +cleanup() { |
| 82 | + rm -rf "$SHARED_DIR" |
| 83 | +} |
| 84 | + |
| 85 | +configure_gitops(){ |
| 86 | + GITOPS_IIB_IMAGE="quay.io/rhtap_qe/gitops-iib:782137" |
| 87 | + |
| 88 | + SUBSCRIPTION="openshiftGitOps" |
| 89 | + CHANNEL="latest" |
| 90 | + SOURCE="gitops-iib" |
| 91 | +} |
| 92 | + |
| 93 | +configure_pipelines(){ |
| 94 | + PIPELINES_IMAGE="quay.io/openshift-pipeline/openshift-pipelines-pipelines-operator-bundle-container-index" |
| 95 | + PIPELINES_IMAGE_TAG="v4.17-candidate" |
| 96 | + |
| 97 | + SUBSCRIPTION="openshiftPipelines" |
| 98 | + CHANNEL="latest" |
| 99 | + SOURCE="pipelines-iib" |
| 100 | +} |
| 101 | + |
| 102 | +configure_rhdh(){ |
| 103 | + RHDH_INSTALL_SCRIPT="https://raw.githubusercontent.com/redhat-developer/rhdh-operator/main/.rhdh/scripts/install-rhdh-catalog-source.sh" |
| 104 | + curl -sSLO $RHDH_INSTALL_SCRIPT |
| 105 | + chmod +x install-rhdh-catalog-source.sh |
| 106 | + |
| 107 | + ./install-rhdh-catalog-source.sh --latest --install-operator rhdh |
| 108 | + |
| 109 | + SUBSCRIPTION="redHatDeveloperHub" |
| 110 | + CHANNEL="fast-1.5" |
| 111 | + SOURCE="rhdh-fast" |
| 112 | +} |
| 113 | + |
| 114 | +configure_subscription(){ |
| 115 | + # Prepare for pre-release install capabilities |
| 116 | + subscription_values_file="$PROJECT_DIR/installer/charts/rhtap-subscriptions/values.yaml" |
| 117 | + |
| 118 | + yq -i " |
| 119 | + .subscriptions.$SUBSCRIPTION.channel = \"$CHANNEL\", |
| 120 | + .subscriptions.$SUBSCRIPTION.source = \"$SOURCE\" |
| 121 | + " "$subscription_values_file" |
| 122 | +} |
| 123 | + |
| 124 | +main() { |
| 125 | + parse_args "$@" |
| 126 | + init |
| 127 | + for PRODUCT in "${PRODUCT_LIST[@]}"; do |
| 128 | + |
| 129 | + "configure_$PRODUCT" |
| 130 | + configure_subscription |
| 131 | + done |
| 132 | +} |
| 133 | + |
| 134 | +if [ "${BASH_SOURCE[0]}" == "$0" ]; then |
| 135 | + main "$@" |
| 136 | +fi |
0 commit comments