diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2018-05-24 07:51:40 -0400 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2018-05-26 13:06:52 -0400 |
| commit | d5e17cb1ee87f51d0fd1b3c40e50791ae40e08a0 (patch) | |
| tree | 994baf2d2ebefeb445b6d99fe2bea305233f4c03 /docs | |
| parent | 8c1aa365be022c0c0c33cee8f2dfb9532442d522 (diff) | |
Adding env datasource
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/content/datasources.md | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/docs/content/datasources.md b/docs/content/datasources.md index e80744ee..f31128ae 100644 --- a/docs/content/datasources.md +++ b/docs/content/datasources.md @@ -42,6 +42,7 @@ Gomplate supports a number of datasources, each specified with a particular URL | [AWS Systems Manager Parameter Store](#using-aws-smp-datasources) | `aws+smp` | [AWS Systems Manager Parameter Store][AWS SMP] is a hierarchically-organized key/value store which allows storage of text, lists, or encrypted secrets for retrieval by AWS resources | | [BoltDB](#using-boltdb-datasources) | `boltdb` | [BoltDB][] is a simple local key/value store used by many Go tools | | [Consul](#using-consul-datasources) | `consul`, `consul+http`, `consul+https` | [HashiCorp Consul][] provides (among many other features) a key/value store | +| [Environment](#using-env-datasources) | `env` | Environment variables can be used as datasources - useful for testing | | [File](#using-file-datasources) | `file` | Files can be read in any of the [supported formats](#supported-formats), including by piping through standard input (`Stdin`) | | [HTTP](#using-http-datasources) | `http`, `https` | Data can be sourced from HTTP/HTTPS sites in many different formats. Arbitrary HTTP headers can be set with the [`--datasource-header`/`-H`][] flag | | [Stdin](#using-stdin-datasources) | `stdin` | A special case of the `file` datasource; allows piping through standard input (`Stdin`) | @@ -226,6 +227,35 @@ $ gomplate -d consul=consul:///foo -i '{{(datasource "consul" "bar/baz")}}' value for foo/bar/baz key ``` +## Using `env` datasources + +The `env` datasource type provides access to environment variables. This can be useful for rendering templates that would normally use a different sort of datasource, in test and development scenarios. + +No hierarchy or directory semantics are currently supported. + +**Note:** Variable names are _case-sensitive!_ + +### URL Considerations + +The _scheme_ and either the _path_ or the _opaque_ part are used, and the _query_ component can be used to [override the MIME type](#overriding-mime-types). + +- the _scheme_ must be `env` +- one of the _path_ or _opaque_ component is required, and is interpreted as the environment variable's name. Leading `/` characters are stripped from the _path_. + +### Examples + +```console +$ gomplate -d user=env:USER -i 'Hello {{ include "user" }}!' +Hello hairyhenderson! + +$ gomplate -d homedir=env:///HOME -i '{{ files.IsDir (ds "homedir") }}' +true + +$ export foo='{"one":1, "two":2}' +$ gomplate -d foo=env:/foo?type=application/json -i '{{ (ds "foo").two }}' +2 +``` + ## Using `file` datasources The `file` datasource type provides access to files in any of the [supported formats](#mime-types). [Directory datasource](#directory-datasources) semantics are supported. |
