|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | + |
| 4 | +set -euo pipefail |
| 5 | + |
| 6 | +# This script is used to install OLMv1 from the main branch by: |
| 7 | +# 1. Checking out main branch in a temporary location |
| 8 | +# 2. Building container images from main source code |
| 9 | +# 3. Loading images into the kind cluster |
| 10 | +# 4. Deploying manifests from main |
| 11 | + |
| 12 | + |
| 13 | +help="install-from-main.sh installs OLMv1 from main branch source code |
| 14 | +
|
| 15 | +Usage: |
| 16 | + install-from-main.sh [MANIFEST_NAME] |
| 17 | +
|
| 18 | +Example: |
| 19 | + install-from-main.sh experimental.yaml |
| 20 | + install-from-main.sh standard.yaml |
| 21 | +
|
| 22 | +Environment variables: |
| 23 | + KIND_CLUSTER_NAME: Name of the kind cluster (required) |
| 24 | +" |
| 25 | + |
| 26 | +if [[ "$#" -ne 1 ]]; then |
| 27 | + echo "Illegal number of arguments passed" |
| 28 | + echo "${help}" |
| 29 | + exit 1 |
| 30 | +fi |
| 31 | + |
| 32 | +if [[ -z "${KIND_CLUSTER_NAME:-}" ]]; then |
| 33 | + echo "Error: KIND_CLUSTER_NAME environment variable must be set" |
| 34 | + exit 1 |
| 35 | +fi |
| 36 | + |
| 37 | +MANIFEST_NAME=$1 |
| 38 | + |
| 39 | +# Create temporary directory for main branch checkout |
| 40 | +TEMP_DIR=$(mktemp -d) |
| 41 | +trap 'echo "Cleaning up ${TEMP_DIR}"; rm -rf "${TEMP_DIR}"' EXIT |
| 42 | + |
| 43 | +echo "Cloning main branch to temporary directory..." |
| 44 | +# Clone from GitHub (works in CI and locally) |
| 45 | +git clone --depth 1 --branch main https://github.com/operator-framework/operator-controller.git "${TEMP_DIR}" |
| 46 | + |
| 47 | +cd "${TEMP_DIR}" |
| 48 | + |
| 49 | +echo "Building images from main branch source code..." |
| 50 | +make docker-build |
| 51 | + |
| 52 | +echo "Loading images into kind cluster ${KIND_CLUSTER_NAME}..." |
| 53 | +make kind-load KIND_CLUSTER_NAME="${KIND_CLUSTER_NAME}" |
| 54 | + |
| 55 | +echo "Deploying manifests from main branch..." |
| 56 | +# Extract CERT_MGR_VERSION from main branch Makefile |
| 57 | +# Expected Makefile line format: export CERT_MGR_VERSION := <value> |
| 58 | +CERT_MGR_VERSION_FROM_MAIN=$(grep "^export CERT_MGR_VERSION" Makefile | awk -F'[ :=]+' '{print $NF}') |
| 59 | +export CERT_MGR_VERSION="${CERT_MGR_VERSION_FROM_MAIN:-v1.18.2}" |
| 60 | +export MANIFEST="https://raw.githubusercontent.com/operator-framework/operator-controller/main/manifests/${MANIFEST_NAME}" |
| 61 | +export DEFAULT_CATALOG="https://raw.githubusercontent.com/operator-framework/operator-controller/main/manifests/default-catalogs.yaml" |
| 62 | +export INSTALL_DEFAULT_CATALOGS="${INSTALL_DEFAULT_CATALOGS:-false}" |
| 63 | + |
| 64 | +curl -L -s https://raw.githubusercontent.com/operator-framework/operator-controller/main/scripts/install.tpl.sh | \ |
| 65 | + envsubst '$$DEFAULT_CATALOG,$$CERT_MGR_VERSION,$$INSTALL_DEFAULT_CATALOGS,$$MANIFEST' | bash -s |
| 66 | + |
| 67 | +echo "Successfully installed OLMv1 from main branch" |
| 68 | + |
0 commit comments