|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# |
| 4 | +# For help and usage information, simply execute the script w/o any arguments. |
| 5 | +# |
| 6 | +# This script is intended to be run by Red Hat dnsname developers who need |
| 7 | +# to debug problems specifically related to Cirrus-CI automated testing. |
| 8 | +# It requires that you have been granted prior access to create VMs in |
| 9 | +# google-cloud. For non-Red Hat contributors, VMs are available as-needed, |
| 10 | +# with supervision upon request. |
| 11 | + |
| 12 | +set -e |
| 13 | + |
| 14 | +SCRIPT_FILEPATH=$(realpath "${BASH_SOURCE[0]}") |
| 15 | +SCRIPT_DIRPATH=$(dirname "$SCRIPT_FILEPATH") |
| 16 | +REPO_DIRPATH=$(realpath "$SCRIPT_DIRPATH/../") |
| 17 | + |
| 18 | +# Help detect if we were called by get_ci_vm container |
| 19 | +GET_CI_VM="${GET_CI_VM:-0}" |
| 20 | +in_get_ci_vm() { |
| 21 | + if ((GET_CI_VM==0)); then |
| 22 | + echo "Error: $1 is not intended for use in this context" |
| 23 | + exit 2 |
| 24 | + fi |
| 25 | +} |
| 26 | + |
| 27 | +# get_ci_vm APIv1 container entrypoint calls into this script |
| 28 | +# to obtain required repo. specific configuration options. |
| 29 | +if [[ "$1" == "--config" ]]; then |
| 30 | + in_get_ci_vm "$1" |
| 31 | + cat <<EOF |
| 32 | +DESTDIR="/var/tmp/go/src/github.com/containers/dnsname" |
| 33 | +UPSTREAM_REPO="https://github.com/containers/dnsname.git" |
| 34 | +CI_ENVFILE="/etc/ci_environment" |
| 35 | +GCLOUD_PROJECT="dnsname-8675309" |
| 36 | +GCLOUD_IMGPROJECT="libpod-218412" |
| 37 | +GCLOUD_CFG="dnsname" |
| 38 | +GCLOUD_ZONE="${GCLOUD_ZONE:-us-central1-c}" |
| 39 | +GCLOUD_CPUS="2" |
| 40 | +GCLOUD_MEMORY="4Gb" |
| 41 | +GCLOUD_DISK="200" |
| 42 | +EOF |
| 43 | +elif [[ "$1" == "--setup" ]]; then |
| 44 | + in_get_ci_vm "$1" |
| 45 | + # get_ci_vm container entrypoint calls us with this option on the |
| 46 | + # Cirrus-CI environment instance, to perform repo.-specific setup. |
| 47 | + echo "+ Setting up environment" > /dev/stderr |
| 48 | + echo 'PATH=$PATH:$GOPATH/bin' > /etc/ci_environment |
| 49 | +else |
| 50 | + # Create and access VM for specified Cirrus-CI task |
| 51 | + mkdir -p $HOME/.config/gcloud/ssh |
| 52 | + podman run -it --rm \ |
| 53 | + --tz=local \ |
| 54 | + -e NAME="$USER" \ |
| 55 | + -e SRCDIR=/src \ |
| 56 | + -e GCLOUD_ZONE="$GCLOUD_ZONE" \ |
| 57 | + -e DEBUG="${DEBUG:-0}" \ |
| 58 | + -v $REPO_DIRPATH:/src:O \ |
| 59 | + -v $HOME/.config/gcloud:/root/.config/gcloud:z \ |
| 60 | + -v $HOME/.config/gcloud/ssh:/root/.ssh:z \ |
| 61 | + quay.io/libpod/get_ci_vm:latest "$@" |
| 62 | +fi |
0 commit comments