ns: env preamble: | [12-factor]: https://12factor.net [Docker Secrets]: https://docs.docker.com/engine/swarm/secrets/#build-support-for-docker-secrets-into-your-images funcs: - name: env.Getenv alias: getenv released: v0.2.0 description: | Exposes the [os.Getenv](https://pkg.go.dev/os/#Getenv) function. Retrieves the value of the environment variable named by the key. If the variable is unset, but the same variable ending in `_FILE` is set, the contents of the file will be returned. Otherwise the provided default (or an empty string) is returned. This is a more forgiving alternative to using `.Env`, since missing keys will return an empty string, instead of panicking. The `_FILE` fallback is especially useful for use with [12-factor][]-style applications configurable only by environment variables, and especially in conjunction with features like [Docker Secrets][]. pipeline: false arguments: - name: var required: true description: the environment variable name - name: default required: false description: the default examples: - | $ gomplate -i 'Hello, {{env.Getenv "USER"}}' Hello, hairyhenderson $ gomplate -i 'Hey, {{getenv "FIRSTNAME" "you"}}!' Hey, you! - | $ echo "safe" > /tmp/mysecret $ export SECRET_FILE=/tmp/mysecret $ gomplate -i 'Your secret is {{getenv "SECRET"}}' Your secret is safe - name: env.ExpandEnv released: v2.5.0 description: | Exposes the [os.ExpandEnv](https://pkg.go.dev/os/#ExpandEnv) function. Replaces `${var}` or `$var` in the input string according to the values of the current environment variables. References to undefined variables are replaced by the empty string. Like [`env.Getenv`](#envgetenv), the `_FILE` variant of a variable is used. pipeline: false arguments: - name: input required: true description: the input examples: - | $ gomplate -i '{{env.ExpandEnv "Hello $USER"}}' Hello, hairyhenderson $ gomplate -i 'Hey, {{env.ExpandEnv "Hey, ${FIRSTNAME}!"}}' Hey, you! - | $ echo "safe" > /tmp/mysecret $ export SECRET_FILE=/tmp/mysecret $ gomplate -i '{{env.ExpandEnv "Your secret is $SECRET"}}' Your secret is safe - | $ gomplate -i '{{env.ExpandEnv (file.Read "foo")}} contents of file "foo"...