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