sigil icon indicating copy to clipboard operation
sigil copied to clipboard

feature request: accept file of variables

Open munkyboy opened this issue 7 years ago • 5 comments

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

munkyboy avatar Jul 11 '17 19:07 munkyboy

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')

etoews avatar Jul 28 '17 14:07 etoews

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

progrium avatar Jul 28 '17 16:07 progrium

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?

etoews avatar Jul 28 '17 19:07 etoews

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 avatar May 14 '19 11:05 KarelWintersky

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

KarelWintersky avatar May 14 '19 11:05 KarelWintersky