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

Anchoring "cross load()" #2175

Open
rpnidgit opened this issue Oct 15, 2024 · 1 comment
Open

Anchoring "cross load()" #2175

rpnidgit opened this issue Oct 15, 2024 · 1 comment

Comments

@rpnidgit
Copy link

load() seems to confine all anchoring/aliasing to the loaded file, not allowing any sharing from or to the loading context.

Any chance to change this?

Or maybe I am just thick, and not seeing a proper way to achieve my current goal, which is no less than to split up lengthy files in generic(-ish) fashion, with anchor definitions and references split as well?

@mikefarah
Copy link
Owner

Unfortunately the anchor logic is within the underlying yaml parser library, which only has context of the current yaml document its parsing.

What you can do though, is come up with some sort of convention, say

apple:
  templateReference: data2.yaml
banana: great

Whereby templateReference means you want to substitute the contents with data2.yaml; then you can use yq to do process:

yq ' (.. | select(has("templateReference"))) |= load(.templateReference)' data1.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
@mikefarah @rpnidgit and others