-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for merge tags #121
Comments
I might want to ask: (A) What does https://github.com/yaml/libyaml do? Mostly, because I'm not sure we should add features that aren't widely supported and needed. |
(A) libyaml does not support the merge tag either: yaml/libyaml#168 |
This feature would be great for managing config files with shared properties. For example in the Flutter plugins repository we can create aliases and merge the nodes in to prevent duplication: tool_setup_template: &TOOL_SETUP_TEMPLATE
tool_setup_script:
- .ci/scripts/prepare_tool.sh
...
flutter_upgrade_template: &FLUTTER_UPGRADE_TEMPLATE
upgrade_flutter_script:
- flutter doctor -v
<< : *TOOL_SETUP_TEMPLATE
...
task:
<< : *FLUTTER_UPGRADE_TEMPLATE
gke_container:
dockerfile: .ci/Dockerfile
... I've simplified it copied here but you can see how much duplication this saves: I tried to do something similar in the Flutter repo CI config file, which is using this dart yaml package, but I can't merge the properties because it isn't supported: |
I also found a decent write up here: https://ktomk.github.io/writing/yaml-anchor-alias-and-merge-key.html I have two questions:
To be fair, I'm biased, because I mainly use And for configuration files, features such as:
are often the source of bugs and unnecessary complexity. Aliases and anchors are cool, but our config files are often fairly small, do you really need them? Isn't it better to duplicate the config? Because aliases and anchors are supported Adding support for merge keys would be another feature that would be extremely hard to support in tooling that edits YAML files. It would probably also result in weird error messages, because So personally, unless there is a really compelling reason. Unless all other YAML packages do implement this feature. And unless it can't be implemented in a post-processing step, I'd suggest we just don't support this in I suspect merge tags could be supported through post-processing, which could live happily in a community owned |
It can be done in post-process step but requires knowledge about anchors. If these are available than it's ok to implement one. |
The yaml package (in v2.3.0 at least) does not support
!!merge
tags.For implicit instances (with only a map key of
<<
) it gets just interpreted as a!!str
node.If the
!!merge
tag is given explicitly an exception is thrown.outputs
The text was updated successfully, but these errors were encountered: