mirror of
https://github.com/nickyeoman/docker-compose-cookbooks.git
synced 2026-09-04 02:46:23 +00:00
Bookstack, test works
This commit is contained in:
+8
-23
@@ -7,31 +7,16 @@ process_env_vars() {
|
||||
|
||||
# Loop through each environment variable
|
||||
while IFS= read -r env_var; do
|
||||
# Split into name and value parts based on '='
|
||||
var_name="${env_var%%=*}" # Variable name
|
||||
var_value="${env_var#*=}" # Variable value
|
||||
# Split into name and value parts based on ':'
|
||||
var_name="${env_var%%:*}" # Variable name
|
||||
var_value="${env_var#*:}" # Variable value
|
||||
|
||||
# Handle variables without existing braces (not previously processed)
|
||||
if [[ "$var_value" != *'${'* ]]; then
|
||||
modified_var="${var_name}: \${${APP_NAME}_${var_name}:-${var_value}}"
|
||||
else
|
||||
# Handle variables already having ${} and possible default
|
||||
ref_var="${var_value#\$\{}"
|
||||
ref_var="${ref_var%%[:-]*}"
|
||||
# Remove leading and trailing whitespace
|
||||
var_name=$(echo "$var_name" | xargs)
|
||||
var_value=$(echo "$var_value" | xargs)
|
||||
|
||||
# Extract the default value part
|
||||
default_value="${var_value##*:-}"
|
||||
default_value="${default_value%\}}"
|
||||
|
||||
# Check if the reference variable already contains APP_NAME_ prefix
|
||||
if [[ "$ref_var" == ${APP_NAME}_* ]]; then
|
||||
# Use the reference variable as is if it already contains the prefix
|
||||
modified_var="${var_name}: \${${ref_var}:-${default_value}}"
|
||||
else
|
||||
# Add APP_NAME_ prefix to reference variable
|
||||
modified_var="${var_name}: \${${APP_NAME}_${ref_var}:-${default_value}}"
|
||||
fi
|
||||
fi
|
||||
# Format the variable as required
|
||||
modified_var="${var_name}=\${${APP_NAME}_${var_name}:-${var_value}}"
|
||||
|
||||
# Append the modified variable to results
|
||||
results+=("$modified_var")
|
||||
|
||||
@@ -20,6 +20,7 @@ get_env_vars() {
|
||||
|
||||
echo "$env_vars"
|
||||
}
|
||||
|
||||
get_image() {
|
||||
local compose_content="$1"
|
||||
local images=""
|
||||
|
||||
Reference in New Issue
Block a user