forked from operator-framework/community-operators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv
executable file
·76 lines (62 loc) · 2.82 KB
/
env
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env bash
export $(grep -v '^MAKE' /tmp/env.conf)
for f in "$(cd "$(dirname ${BASH_SOURCE[0]})/.." && pwd)"/lib/*; do
. "$f"
done
# Relative path to the dir containing operator manifests. Usually something
# like "community-operators/automationbroker".
[[ -z "$OP_PATH" ]] && OP_PATH="$1"
if [[ ! -d "$OP_PATH" ]]; then
>&2 echo "Relative path to operator package '$OP_PATH' does not exist."
exit 1
fi
export PKG_FILE="$(find "$OP_PATH" -name "*.package.yaml" -print -quit)"
export DISTRO_TYPE_UPSTREAM="upstream"
export DISTRO_TYPE_OPENSHIFT="openshift"
export DISTRO_TYPE="${3:-$DISTRO_TYPE_UPSTREAM}"
if [[ "$DISTRO_TYPE" != "$DISTRO_TYPE_UPSTREAM" && "$DISTRO_TYPE" != "$DISTRO_TYPE_OPENSHIFT" ]]; then
>&2 echo "DISTRO_TYPE \"$DISTRO_TYPE\" is not valid. Must be one of: \"$DISTRO_TYPE_UPSTREAM\", \"$DISTRO_TYPE_OPENSHIFT\"."
exit 1
fi
if [[ "$DISTRO_TYPE" == "$DISTRO_TYPE_OPENSHIFT" ]]; then
if [[ -z "$KUBECONFIG" || ! -e "$KUBECONFIG" ]]; then
>&2 echo "KUBECONFIG not available."
exit 1
fi
fi
set -u
export DEPLOY_DIR="${TMP}/deploy"
export PKG_NAME="$(yq r "$PKG_FILE" "packageName")"
export ABS_BUNDLE_PATH="${DEPLOY_DIR}/${PKG_NAME}/${OP_VER}"
export CR_DIR="${DEPLOY_DIR}/crs"
mkdir -p "$ABS_BUNDLE_PATH"
mkdir -p "$CR_DIR"
# Organize expected dir structure for the registry image build.
operator-courier nest "${OP_PATH}" "${DEPLOY_DIR}/${PKG_NAME}" 2> /dev/null
pushd "$DEPLOY_DIR" >/dev/null
# Set PKG_FILE again with the nested path.
export PKG_FILE="$(find "$DEPLOY_DIR" -name "*.package.yaml" -print -quit)"
export CATALOGSOURCE_FILE="catalogsource.yaml"
export SUBSCRIPTION_FILE="${PKG_NAME}.subscription.yaml"
export OPERATOR_GROUP_FILE="${PKG_NAME}.operatorgroup.yaml"
export SC_PROXY_IMAGE="quay.io/operator-framework/scorecard-proxy:master"
# Make sure this registry is public before proceeding.
export OP_REGISTRY_IMAGE="quay.io/operatorframework/${PKG_NAME}:${OP_VER}-registry"
export SECRET_FILE="${DEPLOY_DIR}/scorecard.secret.yaml"
export CSV_FILE="$(find "$ABS_BUNDLE_PATH" -name "*${OP_VER}.clusterserviceversion.yaml" -print -quit)"
mkdir -p /tmp/scorecard-bundles
python3 /scripts/lib-python/files/create_operator_scorecard_bundle.py -r "$CR_DIR" -c "$ABS_BUNDLE_PATH" -b /tmp/scorecard-bundles -v "$CSV_FILE" -n "$NAMESPACE" -p "$SC_PROXY_IMAGE" -d "$ABS_BUNDLE_PATH"
if [[ -f $CSV_FILE ]]; then
if [[ -z ${INSTALL_MODE} ]]; then
export INSTALL_MODE="$(python3 /scripts/lib-python/files/detect_install_mode.py --csvfile "$CSV_FILE")"
fi
export CSV_NAME="$(yq r "$CSV_FILE" "metadata.name")"
export CHANNEL_NAME="$(python3 /scripts/lib-python/cluster/get_operator_channel.py -p "$PKG_FILE" -c "$CSV_NAME")"
set +u
if [[ "$REG_IMAGE" ]]; then
export OP_REGISTRY_IMAGE="${REG_IMAGE}"
fi
else
>&2 echo "CSV file for version ${OP_VER} not found test cannot continue"
exit 1;
fi