docker: skip temporary installation of disabled items (#2018)

This commit is contained in:
mmetc 2023-01-26 17:13:57 +01:00 committed by GitHub
parent e37d09e5b4
commit 3bf95e1a83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -106,11 +106,41 @@ cscli_if_clean() {
if cscli "$1" inspect "$obj" -o json | yq -e '.tainted // false' >/dev/null 2>&1; then
echo "Object $1/$obj is tainted, skipping"
else
cscli "$1" "$2" "$obj"
# # Too verbose? Only show errors if not in debug mode
# if [ "$DEBUG" != "true" ]; then
# error_only=--error
# fi
error_only=""
echo "Running: cscli $error_only $1 $2 \"$obj\""
# shellcheck disable=SC2086
cscli $error_only "$1" "$2" "$obj"
fi
done
}
# Output the difference between two lists
# of items separated by spaces
difference() {
list1="$1"
list2="$2"
# split into words
# shellcheck disable=SC2086
set -- $list1
for item in "$@"; do
found=false
for i in $list2; do
if [ "$item" = "$i" ]; then
found=true
break
fi
done
if [ "$found" = false ]; then
echo "$item"
fi
done
}
#-----------------------------------#
if [ -n "$CERT_FILE" ] || [ -n "$KEY_FILE" ] ; then
@ -267,22 +297,22 @@ cscli_if_clean parsers install crowdsecurity/cri-logs
if [ "$COLLECTIONS" != "" ]; then
# shellcheck disable=SC2086
cscli_if_clean collections install "$COLLECTIONS"
cscli_if_clean collections install "$(difference "$COLLECTIONS" "$DISABLE_COLLECTIONS")"
fi
if [ "$PARSERS" != "" ]; then
# shellcheck disable=SC2086
cscli_if_clean parsers install "$PARSERS"
cscli_if_clean parsers install "$(difference "$PARSERS" "$DISABLE_PARSERS")"
fi
if [ "$SCENARIOS" != "" ]; then
# shellcheck disable=SC2086
cscli_if_clean scenarios install "$SCENARIOS"
cscli_if_clean scenarios install "$(difference "$SCENARIOS" "$DISABLE_SCENARIOS")"
fi
if [ "$POSTOVERFLOWS" != "" ]; then
# shellcheck disable=SC2086
cscli_if_clean postoverflows install "$POSTOVERFLOWS"
cscli_if_clean postoverflows install "$(difference "$POSTOVERFLOWS" "$DISABLE_POSTOVERFLOWS")"
fi
## Remove collections, parsers, scenarios & postoverflows