mattcasters opened a new pull request, #7367:
URL: https://github.com/apache/hop/pull/7367
# Walkthrough - Fixing Docker variable quoting for HOP_START_ACTION
This walkthrough describes the root cause and the fix for the issue where
using `HOP_START_ACTION` with spaces in the Docker container fails.
## Root Cause Analysis
In `docker/resources/load-and-execute.sh`, options were concatenated into a
single string variable `HOP_EXEC_OPTIONS`:
```bash
HOP_EXEC_OPTIONS="${HOP_EXEC_OPTIONS} --startaction=${HOP_START_ACTION}"
```
When executing the underlying `hop-run.sh` or `hop` command,
`${HOP_EXEC_OPTIONS}` was passed unquoted to allow multiple flags to be passed
as separate arguments:
```bash
"${DEPLOYMENT_PATH}"/hop-run.sh \
--file="${HOP_FILE_PATH}" \
--runconfig="${HOP_RUN_CONFIG}" \
--parameters="${HOP_RUN_PARAMETERS}" \
${HOP_EXEC_OPTIONS} \
...
```
Due to the lack of quoting around `${HOP_EXEC_OPTIONS}`, the shell performed
word splitting on whitespace. If `HOP_START_ACTION` contained spaces (e.g. `"My
Fancy Action"`), the parameter was split into multiple arguments:
`--startaction=My`, `Fancy`, and `Action`.
## Implementation Details
To properly preserve spaces in arguments, `HOP_EXEC_OPTIONS` was converted
into a Bash array (`HOP_EXEC_OPTIONS=()`).
Options are now appended to the array:
- `HOP_EXEC_OPTIONS+=("--level=${HOP_LOG_LEVEL}")`
- `HOP_EXEC_OPTIONS+=("--system-properties=${HOP_SYSTEM_PROPERTIES}")`
- `HOP_EXEC_OPTIONS+=("--project=${HOP_PROJECT_NAME}")`
- `HOP_EXEC_OPTIONS+=("--environment=${HOP_ENVIRONMENT_NAME}")`
- `HOP_EXEC_OPTIONS+=("--metadata-export=${HOP_RUN_METADATA_EXPORT}")`
- `HOP_EXEC_OPTIONS+=("--startaction=${HOP_START_ACTION}")`
When executing downstream scripts, the array is expanded with quotes
`"${HOP_EXEC_OPTIONS[@]}"`, which correctly preserves each option (including
those with spaces) as a single distinct argument.
### Modified Files
-
[load-and-execute.sh](file:///home/matt/git/mattcasters/hop/docker/resources/load-and-execute.sh)
### Testing
Ran `integration-tests/scripts/run-tests-docker.sh PROJECT_NAME=actions` to
make sure the old behavior still works as expected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]