forked from operator-framework/community-operators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoperator-test
executable file
·50 lines (35 loc) · 1.77 KB
/
operator-test
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
#!/usr/bin/env bash
# This script transforms an operator dir structured in the style of
# community-operators into one expected by operator-registry, inserts the
# scorecard proxy container, and proxy kubeconfig secret, volume, and mount
# into a CSV, creates CR's from CSV metadata, deploys the operator with the
# OLM in a local cluster, and runs the SDK scorecard against the operator.
set -e
cd /
. /scripts/ci/env
KUBECONFIG=~/.kube/config
export_color
#trap_add_exit "rm -rf $TMP"
set -u
# Define names for resource types.
export DEP_NAME="$(yq r "$CSV_FILE" "spec.install.spec.deployments[0].name")"
declare -A OBJECTS
OBJECTS=(
["catalogsource"]="$(yq r "$CATALOGSOURCE_FILE" "metadata.name")"
["subscription"]="$(yq r "$SUBSCRIPTION_FILE" "metadata.name")"
["csv"]="$CSV_NAME"
["deployment"]="$DEP_NAME"
)
printf "Operator Deployment %s\t[ ${WARN} Processing ${NC} ]\n" | expand -t 50 >&2
if [[ -f "$OPERATOR_GROUP_FILE" ]]; then
OBJECTS+=(["operatorgroup"]="$(yq r "$OPERATOR_GROUP_FILE" "metadata.name")")
fi
/scripts/ci/run-script "apply_objects_incluster $DEPLOY_DIR" " Applying object to cluster"
/scripts/ci/run-script "check_subscription_passes ${PKG_NAME}-sub $NAMESPACE $PKG_NAME" " Checking if subscriptions passes"
# Wait for csv, then check that clusterserviceversion has Succeeded
sleep 6
/scripts/ci/run-script "check_csv_passes $CSV_NAME $NAMESPACE $INSTALL_MODE" " Checking if CSV passes"
/scripts/ci/run-script "sleep 60" " Ensuring CSV stays alive"
/scripts/ci/run-script "check_csv_passes $CSV_NAME $NAMESPACE $INSTALL_MODE" " Checking if CSV stayed alive for 60 secs"
# /scripts/ci/run-script "wait_on_deployment $DEP_NAME $NAMESPACE" " Waiting for deployment"
printf "Operator Deployment %s\t[ ${OK} OK ${NC} ]\n" | expand -t 50 >&2