diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2016-01-24 20:07:36 -0500 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2016-05-19 16:38:04 -0400 |
| commit | cb5774a31d2ac883db87f27fe2942b8ea7975b70 (patch) | |
| tree | 29e5a83b603d9f9b0756a048deef1d8af8ea7e5d /README.md | |
| parent | cc70da900865809abd2affdd0bbb426bedbbcfde (diff) | |
New datasource function - works for JSON files
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 41 |
1 files changed, 41 insertions, 0 deletions
@@ -24,6 +24,22 @@ $ echo "Hello, {{.Env.USER}}" | gomplate Hello, hairyhenderson ``` +### Commandline Arguments + +#### `--datasource`/`-d` + +Add a data source in `name=URL` form. Specify multiple times to add multiple sources. The data can then be used by the [`datasource`](#datasource) function. + +A few different forms are valid: +- `mydata=file:///tmp/my/file.json` + - Create a data source named `mydata` which is read from `/tmp/my/file.json`. This form is valid for any file in any path. +- `mydata=file.json` + - Create a data source named `mydata` which is read from `file.json` (in the current working directory). This form is only valid for files in the current directory. +- `mydata.json` + - This form infers the name from the file name (without extension). Only valid for files in the current directory. + +## Syntax + #### About `.Env` You can easily access environment variables with `.Env`, but there's a catch: @@ -130,6 +146,31 @@ $ gomplate < input.tmpl Hello world ``` +#### `datasource` + +Parses a given datasource (provided by the [`--datasource/-d`](#--datasource-d) argument). + +Currently, only `file://` URLs are supported, and only the JSON format can be parsed. More support is coming. + +##### Example + +_`person.json`:_ +```json +{ + "name": "Dave" +} +``` + +_`input.tmpl`:_ +``` +Hello {{ (datasource "person").name }} +``` + +```console +$ gomplate -d person.json < input.tmpl +Hello Dave +``` + #### `ec2meta` Queries AWS [EC2 Instance Metadata](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html) for information. This only retrieves data in the `meta-data` path -- for data in the `dynamic` path use `ec2dynamic`. |
