From f2946e6cf6f9b120789002c4466f79f09a77dcbf Mon Sep 17 00:00:00 2001 From: Nicholas Malcolm Date: Mon, 11 Dec 2023 22:22:28 -0500 Subject: [PATCH] docs: Fix the Bootstrap script skipping similar name groups Existing logic used jq's contain which confusingly will do partial string matches. For example a group named "media_admin" will be created then "media" will be skipped saying it already exists. --- example_configs/bootstrap/bootstrap.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example_configs/bootstrap/bootstrap.sh b/example_configs/bootstrap/bootstrap.sh index acdfeb4..b1f7096 100755 --- a/example_configs/bootstrap/bootstrap.sh +++ b/example_configs/bootstrap/bootstrap.sh @@ -111,7 +111,7 @@ get_group_array() { } group_exists() { - if [[ "$(get_group_list | jq --raw-output --arg displayName "$1" '.data.groups | any(.[]; contains({"displayName": $displayName}))')" == 'true' ]]; then + if [[ "$(get_group_list | jq --raw-output --arg displayName "$1" '.data.groups | any(.[]; select(.displayName == $displayName))')" == 'true' ]]; then return 0 else return 1 @@ -187,7 +187,7 @@ user_in_group() { return fi - if [[ "$(get_user_details "$user_id" | jq --raw-output --arg displayName "$group_name" '.data.user.groups | any(.[]; contains({"displayName": $displayName}))')" == 'true' ]]; then + if [[ "$(get_user_details "$user_id" | jq --raw-output --arg displayName "$group_name" '.data.user.groups | any(.[]; select(.displayName == $displayName))')" == 'true' ]]; then return 0 else return 1