Skip to content

Commit

Permalink
Handle whitespace in option values
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuru committed Jan 20, 2025
1 parent ca10994 commit 6167248
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ReleaseNotes-v4.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ running `geodesic stop`, the `ON_CONTAINER_EXIT` command may be called twice.
This is because the wrapper calls the command when the container has stopped
before shell exit processing has finished, and both shells fit the criterion.

Now that shells normally exit cleanly (pretty much as long as you do not
Now that shells normally exit cleanly (provided you do not
run `docker kill geodesic`), you may find that you get more reliable behavior
out of:

Expand Down
1 change: 0 additions & 1 deletion docs/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ At its core, Geodesic is a framework for provisioning cloud infrastructure and t
* [`terraform`](https://github.com/hashicorp/terraform/) for provisioning miscellaneous resources on pretty much any cloud
* [`tmate`](https://tmate.io) for remote terminal sharing with other engineers (pairing) and collaborative debugging


## SEE MORE

Extensive documentation is provided on our [Documentation Hub](https://docs.cloudposse.com/resources/legacy/fundamentals/geodesic/).
16 changes: 11 additions & 5 deletions rootfs/templates/wrapper-body.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ require_installed tr
require_installed grep
require_installed docker

docker ps >/dev/null 2>&1
if [ $? -ne 0 ]; then
if ! docker ps >/dev/null 2>&1; then
echo "Unable to communicate with docker daemon. Make sure your environment is properly configured and then try again."
exit 1
fi
Expand Down Expand Up @@ -188,15 +187,15 @@ function options_to_env() {
local k
local v

for option in ${options[@]}; do
for option in "${options[@]}"; do
kv=(${option/=/ })
k=${kv[0]} # Take first element as key
k=${k#--} # Strip leading --
k=${k//-/_} # Convert dashes to underscores
k=$(echo $k | tr '[:lower:]' '[:upper:]') # Convert to uppercase (bash3 compat)

v=${kv[1]} # Treat second element as value
v=${v:-true} # Set it to true for boolean flags
v="${kv[@]:1}" # Treat remaining elements as value
v="${v:-true}" # Set it to true for boolean flags

export $k="$v"
done
Expand Down Expand Up @@ -423,6 +422,10 @@ function use() {
git rev-parse --show-toplevel 2>/dev/null
)
[ "$?" -eq 33 ] && exit 33 # do not abort if git rev-parse fails
# Resolve symbolic links to get the actual path
local configured_wfhd
configured_wfhd="$WORKSPACE_FOLDER_HOST_DIR"
WORKSPACE_FOLDER_HOST_DIR="$(cd "${WORKSPACE_FOLDER_HOST_DIR}" && pwd -P || echo "${WORKSPACE_FOLDER_HOST_DIR}")"
if [ -z "${git_root}" ] || [ "$git_root" = "${WORKSPACE_FOLDER_HOST_DIR}" ]; then
# WORKSPACE_HOST_PATH is the directory on the host that is to be mounted into the container
WORKSPACE_MOUNT_HOST_DIR="${WORKSPACE_FOLDER_HOST_DIR}"
Expand All @@ -432,6 +435,9 @@ function use() {
WORKSPACE_MOUNT_HOST_DIR="${git_root}"
WORKSPACE_FOLDER="${WORKSPACE_FOLDER:-${WORKSPACE_MOUNT}/${WORKSPACE_FOLDER_HOST_DIR#${git_root}/}}"
fi
if [ "$configured_wfhd" != "$WORKSPACE_FOLDER_HOST_DIR" ]; then
echo "# Resolved ${configured_wfhd} to '${WORKSPACE_FOLDER_HOST_DIR}'"
fi

echo "# Mounting '${WORKSPACE_MOUNT_HOST_DIR}' into container at '${WORKSPACE_MOUNT}'"
echo "# Setting container working directory to '${WORKSPACE_FOLDER}'"
Expand Down

0 comments on commit 6167248

Please sign in to comment.