-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Handle multiline strings in yaml serialization. (#935)
**Pull Request Checklist** - [x] Tests added - [x] [Good commit messages](https://cbea.ms/git-commit/) and/or PR title **Description of PR** Currently, multiline strings serialize to yaml in a way that is not true to the original content. For example, copying [argo workflows' exit-handler example](https://github.com/argoproj/argo-workflows/blob/main/examples/exit-handler-slack.yaml) excerpt: ```yaml args: [ "curl -X POST --data-urlencode 'payload={ \"text\": \"{{workflow.name}} finished\", \"blocks\": [ { \"type\": \"section\", \"text\": { \"type\": \"mrkdwn\", \"text\": \"Workflow {{workflow.name}} {{workflow.status}}\", } } ] }' YOUR_WEBHOOK_URL_HERE" ] ``` currently produces: ```yaml args: - "curl -X POST --data-urlencode 'payload={\n \"text\": \"{{workflow.name}}\ \ finished\",\n \"blocks\": [\n {\n \"\ type\": \"section\",\n \"text\": {\n \"type\"\ : \"mrkdwn\",\n \"text\": \"Workflow {{workflow.name}} {{workflow.status}}\"\ ,\n }\n }\n ]\n }'\n YOUR_WEBHOOK_URL_HERE\"\ \n " ``` whereas this PR produces: ```yaml args: - |- curl -X POST --data-urlencode 'payload={ "text": "{{workflow.name}} finished", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "Workflow {{workflow.name}} {{workflow.status}}", } } ] }' YOUR_WEBHOOK_URL_HERE"; ``` --- Note that this does not fix yaml/pyyaml#121 (comment). That is, the following example will revert back to original formatting due to the trailing `\n` at the end of the string. ```python args=""" two """ ``` I would suggest switching `ruamel.yaml` over pyyaml just generally, which would fix this issue, but that's probably going to be considered a breaking change. In any case is probably more tangential to the root issue above (which affects both libraries in the same way). --------- Signed-off-by: DanCardin <[email protected]> Signed-off-by: DanCardin <[email protected]> Co-authored-by: Elliot Gunton <[email protected]> Co-authored-by: Flaviu Vadan <[email protected]>
- Loading branch information
1 parent
4672a9b
commit 571a133
Showing
137 changed files
with
1,446 additions
and
1,521 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.