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: accept file of variables #40

Open
munkyboy opened this issue Jul 11, 2017 · 5 comments
Open

feature request: accept file of variables #40

munkyboy opened this issue Jul 11, 2017 · 5 comments

Comments

@munkyboy
Copy link

it would be nice if sigil could accept a file of variable values

@etoews
Copy link

etoews commented Jul 28, 2017

I just ran into the need for this feature too.

In my case I need to use the variable values from a Terraform .tfvars file in another file. I worked around it with the rather hackish

sigil -f mytemplate.txt $(cat build.tfvars | grep '=' | sed 's/ //g' | sed 's/\n/ /g')

@progrium
Copy link
Contributor

progrium commented Jul 28, 2017 via email

@etoews
Copy link

etoews commented Jul 28, 2017

I think so. In From a file

If a terraform.tfvars file is present in the current directory, Terraform automatically loads it to populate variables. If the file is named something else, you can use the -var-file flag directly to specify a file. These files are the same syntax as Terraform configuration files. And like Terraform configuration files, these files can also be JSON.

Except ours aren't JSON. They're simple key/value pairs, as in the example on that page.

access_key = "foo"
secret_key = "bar"

If you want to support that format too, that would be 💯 but I know you can't support all the formats.

@progrium Do you have an example of exactly how sigil can accept JSON and YAML?

@KarelWintersky
Copy link

KarelWintersky commented May 14, 2019

sigil -f mytemplate.txt $(cat build.tfvars | grep '=' | sed 's/ //g' | sed 's/\n/ /g')

does not work.

sigil -f first.conf $(cat config.conf | grep '=' | sed 's/ //g' | sed 's/\n/ /g')

and first.conf is:

index rt_first {
        type                    = rt
        path                    = $INDEXSTORAGE/first
}

config.conf is:

INDEXSTORAGE = "/var/lib/sphinxsearch/testdata"

Result:

index rt_first {
        type                    = rt
        path                    = $INDEXSTORAGE/first
}

No any changes

@KarelWintersky
Copy link

an example of exactly how sigil can accept JSON

something like:
sigil --template file.txt --replace-json variables.json
sigil --template file.txt --replace-yaml variables.yaml
sigil --template file.txt --replace variables.txt

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

4 participants