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

Allow multiple context(s) #15

Open
IgnisDa opened this issue Jul 24, 2022 · 3 comments
Open

Allow multiple context(s) #15

IgnisDa opened this issue Jul 24, 2022 · 3 comments

Comments

@IgnisDa
Copy link

IgnisDa commented Jul 24, 2022

Awesome library!

I have my data spread over multiple files. But I can specify only one value for context. This is blocking me from using this cli.

@chevdor
Copy link
Owner

chevdor commented Jul 24, 2022

This is not supported on purpose since you can already do that using jq. Check out the --slurp flags. It will allow bringing all your files into a single context.

@michael-robbins
Copy link

michael-robbins commented Sep 12, 2023

(late reply) This would actually be really nice as I might have a mix of JSON and YAML config files in a few directories representing a hierarchy of configs.

I'm currently doing this as:

    yq \
        --output-format json \
        eval-all \
        '. as $item ireduce ({}; . * $item )' \
        "${ROOT_CONFIG.yaml}" \
        "${LEVEL_ONE_CONFIG.json}" \
        "${LEVEL_TWO_CONFIG.yaml}" \
    | \
    tera \
        --template "${TEMPLATE_FILE}" \
        --out "${CONFIG_FILE}" \
        --stdin

But it would be cool to avoid the whole yq and merge logic in there? Or do we think relying on an external process to merge the data structures is the best approach.

@chevdor
Copy link
Owner

chevdor commented Sep 12, 2023

The best way to go is to pick your format, whether json or yaml. Then using tools like jq (I think yq does that to and if not, a round thru jq will do), it is possble to use slurp or slurpfile to aggregate a bunch of json into a single one.
I don't think that making the decisions on how this aggregation should be done, should be performed by the cli.

For instance, you may prefer to aggregate your "sub-json" into an array, or an object... this is out of the scope of the cli.
So in the end, it remains your task to build one context.

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

No branches or pull requests

3 participants