gocd-yaml-config-plugin icon indicating copy to clipboard operation
gocd-yaml-config-plugin copied to clipboard

Support YAML merge syntax

Open michaelbannister opened this issue 7 years ago • 6 comments

On the back of the handy 'common' section introduced in #32, it would be really handy if this plugin supported the YAML merge key, like this:

common:
  material_yaml_config_plugin: &material_yaml_config_plugin
    git: [email protected]:tomzo/gocd-yaml-config-plugin.git
    auto_update: false
  material_gocd:
    git: [email protected]:gocd/gocd.git
    auto_update: false
    blacklist:
      - externals/**/*.*

pipelines:
  a_pipeline:
  materials:
    yaml_config_plugin:
      <<: *material_yaml_config_plugin
      destination: yaml_config_plugin
    gocd:
      <<: *material_gocd
      destination: gocd

I had a look at yamlbeans recently and it seems it now has support for this, but a release has not been made since then. https://github.com/EsotericSoftware/yamlbeans/commit/095d83d

michaelbannister avatar Dec 02 '17 10:12 michaelbannister

I suspect (but have not tested) that this is resolved by #62. Possibly just needs a test or two...

michaelbannister avatar Jan 29 '18 16:01 michaelbannister

I ran into this issue as well... And nope, yamlbeans doesn't support the merge syntax: https://github.com/EsotericSoftware/yamlbeans/blob/master/src/com/esotericsoftware/yamlbeans/tokenizer/Tokenizer.java#L259

Why doesn't this plugin use snakeyaml? It's basically the best yaml parser for java out there, no contest: https://bitbucket.org/asomov/snakeyaml

reegnz avatar Apr 03 '18 10:04 reegnz

Hi @reegnz

Why doesn't this plugin use snakeyaml? It's basically the best yaml parser for java out there, no contest

That wasn't obvious to me 2 years ago, when choosing a parser. It's not like yamlbeans says in the readme that it does not support this and that. If you are confident that snakeyaml would be better, then I have no problem with switching to it. If you or anyone can switch the parser and keep the existing tests passing, that would be great. If you want merge syntax to work, please add at least one test case with use of it.

tomzo avatar Apr 03 '18 10:04 tomzo

Hi @tomzo, I was simply surprized that it didn't use snakeyaml since everywhere you see snakeyaml when you run into yaml parsing in java (eg. https://github.com/FasterXML/jackson-dataformat-yaml). :) I am pretty confident that snakeyaml is the best lib out there for yaml parsing in java. We discussed with my colleagues that we might try and contribute this change.

reegnz avatar Apr 03 '18 11:04 reegnz

Is this still an issue? I see snakeyaml as a dependency in build.graddle

ryudice avatar Apr 13 '20 21:04 ryudice

So is yamlbeans. Checked the code, still using yamlbeans for parsing the config.

reegnz avatar Apr 14 '20 20:04 reegnz