Implementing roles filter for finding proper applications

This commit is contained in:
2022-09-28 07:26:51 +00:00
parent aa78e3bb6f
commit f26c9dc1a2

View File

@@ -24,6 +24,7 @@ EXTRA_OPTIONS="$2 $3 $4"
set | grep SOURCE
set | grep TARGET
set | grep ROLES
# turn on debug mode by extra option "debug"
if [[ "$(echo "$EXTRA_OPTIONS" | grep debug)" != "" ]] ; then
@@ -44,9 +45,19 @@ name_resolver() {
UP=$(docker ps --format '{{.Names}}\t{{.Status}}' | grep Up | awk '{print $1}' | grep $D"-") ;
# filtering for ROLES variables if exists.
if [[ "$ROLES" != "null" && ! -z "$ROLES" ]]; then
UP=$(grep $ROLES $(docker $UP -f '{{.Config.Labels.roles}}'));
fi
if [[ "$ROLES" != "null" && ! -z "$ROLES" ]]; then
UPS=""
for ROLE in $(echo $ROLES); do
FILTERED_BY_ROLE=$(docker inspect $UP -f '{{.Config.Labels.roles}}' | uniq | grep $ROLE)
if [[ "$(echo $FILTERED_BY_ROLE)" != "" ]]; then
UPS="$UPS $UP";
fi
done
UP=$UPS
fi
if [ ! -z "$UP" ] ; then
for D_IP in `echo $UP` ;