forked from operator-framework/community-operators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscorecard
executable file
·54 lines (45 loc) · 1.78 KB
/
scorecard
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
#!/usr/bin/env bash
cd /
. /scripts/ci/env
KUBECONFIG=~/.kube/config
declare -A OBJECTS
OBJECTS=(
["catalogsource"]="$(yq r "$CATALOGSOURCE_FILE" "metadata.name")"
["subscription"]="$(yq r "$SUBSCRIPTION_FILE" "metadata.name")"
["csv"]="$CSV_NAME"
["deployment"]="$DEP_NAME"
)
if [[ -f "$OPERATOR_GROUP_FILE" ]]; then
OBJECTS+=(["operatorgroup"]="$(yq r "$OPERATOR_GROUP_FILE" "metadata.name")")
fi
# Run scorecard tests on the operator.
# TODO: run against multiple CR's. Right now the scorecard only works with one
# CR.
>&2 echo "Running scorecard trough all CR"
for config_file in $(find "/tmp/scorecard-bundles" -name "*.bundle.yaml" -print); do
>&2 echo -e "\n\nRunning operator-sdk scorecard against "$CSV_FILE" with "$config_file""
if ! $(>&2 operator-sdk scorecard -o text --config "$config_file" --kubeconfig "$KUBECONFIG" --verbose --selector="test in (checkspectest,writingintocrshaseffecttest)"); then
echo "FATAL ERROR"
exit 1
fi
if ! $(>&2 operator-sdk scorecard -o text --config "$config_file" --kubeconfig "$KUBECONFIG" --verbose --selector="test in (checkstatustest)"); then
echo "WARNING"
fi
# If scorecard errors out, print out operator logs
if [[ $? != 0 ]]; then
>&2 echo "\nFAIL: Scorecard test errored out. Printing operator state:"
LOG_FILE="${TMP}/info.log"
log_operator_state $LOG_FILE OBJECTS $NAMESPACE
>&2 cat $LOG_FILE
else
echo "PASS: Scorecard test passed"
fi
done
if [[ "$CLEAN_MODE" == "NORMAL" || "$CLEAN_MODE" == "FORCE" ]]; then
echo "Printing operator logs"; get_operator_logs "$CSV_NAME" "$NAMESPACE"
delete_objects_incluster "$DEPLOY_DIR" "$NAMESPACE"
delete_objects_incluster "$ABS_BUNDLE_PATH" "$NAMESPACE"
fi
if [[ "$CLEAN_MODE" == "NORMAL" ]]; then
delete_namespace "$NAMESPACE" "$CLEAN_MODE"
fi