Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(bug) Fix params quoting when using quotes on value (#602)
* (bug) Fix params quoting when using quotes on value Fixes issue with yaml key `params` where it results in different behavior than if the key was passed through env key. Takes an approach that does not require backwards incompatible changes nor does it require changing the schema of yaml files. ------ **Expectation**: using params or env vars would both inject environmental variables into any subprocesses executed in the DAG. **Actual**: they both inject env vars but differ in how they treat quotes. Test dag: ```yaml params: TEST_PARAM="something" TEST_PARAM2="SOMETHING ELSE" env: - ENV_PARAM: "something" steps: - name: step1 command: bash $HOME/src/dagu/tester.sh ``` ``` printf "TEST_PARAM is %s | TEST_PARAM2 is %s\n" "$TEST_PARAM" "$TEST_PARAM2" echo $TEST_PARAM/and/path echo $ENV_PARAM/and/path ``` Results in output: ``` TEST_PARAM is "something" | TEST_PARAM2 is "SOMETHING ELSE" "something"/and/path something/and/path ``` Which is interpreted subtly differently in the inner script and caused me to debug and workaround it for a dag. What I expect as output is: ``` TEST_PARAM is something | TEST_PARAM2 is SOMETHING ELSE something/and/path something/and/path ``` Note the difference for TEST_PARAM and ENV_PARAM. We can't leave off the quote marks for params, otherwise the arguments are parsed incorrectly by splitting on whitespace. Because some users could rely on this behavior, one solution is to enable `params` key to take more structured data, like `env:` key. Like this: ``` params: - TEST_PARAM: "something" - TEST_PARAM2: "SOMETHING ELSE" env: - ENV_PARAM: "something" steps: - name: step1 command: bash $HOME/src/dagu/tester.sh ``` * Adjust tests to reflect there's no forced quoting
- Loading branch information