From 8597b54fbda44abb1a89017f6d496dae05129e5e Mon Sep 17 00:00:00 2001 From: Antonio Vargas Date: Sun, 20 Apr 2025 21:47:10 -0700 Subject: [PATCH] Fix logic to detect user/group config without custom attributes --- scripts/bootstrap.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 7aea0e6..2105700 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -442,14 +442,20 @@ extract_custom_attributes() { fi key=$(echo "$key" | tr -d '"') - + + # If key is empty - this condition traps configurations without custom attributes + if [ -z "$key" ]; then continue; fi + # Get the value local value=$(echo "$json_config" | jq --arg key "$key" '.[$key]') - + + # If the value is null, skip it + if echo "$value" | jq -e 'type == "null"' > /dev/null; then + continue # Check if value is a JSON array - if echo "$value" | jq -e 'type == "array"' > /dev/null; then - # For array types, ensure each element is a string - local array_values=$(echo "$value" | jq 'map(tostring)') + elif echo "$value" | jq -e 'type == "array"' > /dev/null; then + # For array types, ensure each element is a string, use compact JSON + local array_values=$(echo "$value" | jq -c 'map(tostring)') attributes_array+="{\"name\":\"$key\",\"value\":$array_values}" else # For single values, make sure it's a string