Skip to content

Commit

Permalink
Fix the credentials parsing function
Browse files Browse the repository at this point in the history
  • Loading branch information
cbaxley committed Apr 18, 2024
1 parent d2fe08b commit a8ecd56
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/linux_only.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,5 @@ jobs:
run: |
cd testing/development
docker compose -p ${{ env.UNIQUE_ID }} exec -T -u root lme bash -c "rm -rf /home/admin.ackbar/LME/.pytest_cache"
# docker compose -p ${{ env.UNIQUE_ID }} down
# docker system prune -a --force
docker compose -p ${{ env.UNIQUE_ID }} down
docker system prune -a --force
32 changes: 14 additions & 18 deletions testing/configure/lib/functions.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
extract_credentials() {
local file_path=${1:-'/opt/lme/Chapter 3 Files/output.log'}
if [ ! -f "$file_path" ]; then
echo "File not found: $file_path"
return 1
fi
local file_path=${1:-'/opt/lme/Chapter 3 Files/output.log'}

# Use a while loop directly reading from a process substitution
while IFS=: read -r line rest; do
line=$(echo "$line" | sed 's/^## //g' | xargs)
rest=$(echo "$rest" | xargs)
if [ ! -f "$file_path" ]; then
echo "File not found: $file_path"
return 1
fi

key=$(echo "$line" | awk '{print $1}')
value=$rest
# Use sed to extract the lines containing the credentials
credentials=$(sed -n '/^## [a-zA-Z_]*:/p' "$file_path")

case $key in
"elastic" | "kibana" | "logstash_system" | "logstash_writer" | "dashboard_update")
export "$key"="$value"
;;
esac
done < <(awk '/^## \w+:/{print $0}' "$file_path")
# Loop through the extracted lines and assign the values to variables
while IFS=: read -r key value; do
key=$(echo "$key" | sed 's/^## //g' | tr -d '[:space:]')
value=$(echo "$value" | tr -d '\r\n')
export "$key"="$value"
done <<< "$credentials"

export ELASTIC_PASSWORD=$elastic
export ELASTIC_PASSWORD=$elastic
}

write_credentials_to_file() {
Expand Down

0 comments on commit a8ecd56

Please sign in to comment.