sigil
sigil copied to clipboard
feature request: accept file of variables
it would be nice if sigil could accept a file of variable values
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')
Interesting. It can accept json and yaml. Is .tfvars HCL?
On Fri, Jul 28, 2017 at 9:14 AM, Everett Toews [email protected] wrote:
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')
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gliderlabs/sigil/issues/40#issuecomment-318663140, or mute the thread https://github.com/notifications/unsubscribe-auth/AAACh17ZydtmK9PwfjDij50VL33YoWNIks5sSezagaJpZM4OUtw2 .
-- Jeff Lindsay http://progrium.com
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?
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
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