diff --git a/lib/environment.sh b/lib/environment.sh index f350934d..c1ca2aa2 100644 --- a/lib/environment.sh +++ b/lib/environment.sh @@ -41,6 +41,13 @@ configure_environment() { log_info "Worker configuration loaded successfully." + # Export variables from the configuration + log_info "Exporting variables from configuration to environment..." + if ! export_variables_from_config "$resolved_config"; then + log_error "Failed to export variables." + return 1 + fi + # Extract and authenticate actors local actors actors=$(get_config_section "$resolved_config" "actors") diff --git a/lib/worker_config.sh b/lib/worker_config.sh index 4567bbb0..987d8ed9 100644 --- a/lib/worker_config.sh +++ b/lib/worker_config.sh @@ -69,6 +69,27 @@ load_and_parse_config() { echo "$json_output" } +# Export variables from the configuration +export_variables_from_config() { + local config_json="$1" + + log_info "Exporting variables from configuration..." + + # Extract the `variables` section + local variables + variables=$(echo "$config_json" | jq -r '.config.variables // empty') + if [[ -z "$variables" || "$variables" == "null" ]]; then + log_info "No variables found in the configuration." + return 0 + fi + + # Export each variable + echo "$variables" | jq -r 'to_entries[] | "\(.key)=\(.value)"' | while IFS= read -r line; do + export "$line" + log_info "Exported: $line" + done +} + # Function to extract a specific section from the JSON configuration get_config_section() { local config_json="$1"