Skip to content
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

feature request: fully expand merges and anchors #1

Open
nelsonihc opened this issue Jul 7, 2023 · 2 comments
Open

feature request: fully expand merges and anchors #1

nelsonihc opened this issue Jul 7, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@nelsonihc
Copy link

Hi, thanks for developing the tool.

Is it possible to add a flag to fully expand merges and anchors? This tool is great for "rendering" complex .yaml setups and this feature would replace another yaml tool that I'm using to do this expansion.

this behavior is featured in the ruamel.yaml library (python)
$ yaml merge-expand input.yaml output.yaml

Example input:

sitename: website

default: &DEFAULT
  URL: {{sitename}}.com
  mode: production  
  site_name: Website
  some_setting: h2i8yiuhef
  some_other_setting: 3600

development:
  <<: *DEFAULT
  URL: {{sitename}}.local
  mode: dev

test:
  <<: *DEFAULT
  URL: test.{{sitename}}.qa
  mode: test

Example output:

sitename: website

default:
  URL: website.com
  mode: production  
  site_name: Website
  some_setting: h2i8yiuhef
  some_other_setting: 3600

development:
  URL: website.local
  mode: dev
  site_name: Website
  some_setting: h2i8yiuhef
  some_other_setting: 3600

test:
  URL: test.website.qa
  mode: test
  site_name: Website
  some_setting: h2i8yiuhef
  some_other_setting: 3600
@inobelar
Copy link
Owner

inobelar commented Jul 9, 2023

@nelsonihc Hi! :)

Thanks for the feedback! 👍 To be honest, I'm really surprised that this tool was useful to anyone other than me! 😮 You are the first known user, congratulations! 🎉

I quickly wrote it, during the development of more complex tools at my main job, then I posted it in open source (since there is nothing secret in this), but I did not plan to develop it, because the my tasks changed. Now, 2 years later, it will be necessary to remember how everything works there 😄

I like your suggestion - I'll see what can be done, but I can't promise that "soon" (I need to finish the work in the current "context", and only then switch to this "yaml-related").

I propose to leave this issue as a dialogue.

First, my thoughts are:

  • As I can see, examples are given from this StackOverflow answer
  • Possibly it's must be named as 'explode'
  • First of all, the new behavior will be placed under the option;
  • I need to investigate yaml merge-expand / ruyamel behavior, sources & corner cases;
  • We need to decide whether megre-expand will be before "interpolation" or "after", or both - put it under 2 flags like: --merge-expand-pre, --merge-expand-post.
    • It is important to determine the paths during interpolation
  • ... etc ...

I hope you don't need it urgently, I'll write it here when I start working on it.

@inobelar inobelar added the enhancement New feature or request label Jul 9, 2023
@inobelar inobelar self-assigned this Jul 9, 2023
@nelsonihc
Copy link
Author

Hi @inobelar, thanks for the response. I'm glad you embraced the feature request!

Like I stated in the orignal post, I'm using ruaml to achieve this merge-expand so there is no urgency. But I would be glad to remove this python script from my system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants