template

View the Project on GitHub

Installing

Easy install

This command will work on osx, linux-32bit and linux-64bit

curl  https://srossross.github.io/template/get.sh | sh

It will install a single executable file template into /usr/local/bin

Optionally you can set the version os and arch and install prefix

export  TEMPLATE_VERSION=v1.0.0 \
        TEMPLATE_ARCH=arm64 \
        TEMPLATE_OS=linux \
        TEMPLATE_INSTALL_PREFIX=/usr/local/bin

curl srossross.github.io/template/get.sh | bash

Inside a Docker container

FROM ...
ENV TEMPLATE_VERSION v1.0.0
RUN curl srossross.github.io/template/get.sh | sh

Getting Started

Check out the examples directory for a list of examples.
The template command exposes the go template language And adds functions from sprig

This leans heavily from the templates commands of Kubernetes Helm https://docs.helm.sh

My first template

# mytemplate.tpl
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Values.Name }}
data:
  myvalue: "Hello World"

You can run this example like this:

$ template render --set Name=SomeConfig - <<EOF
apiVersion: v1
kind: ConfigMap
metadata:
  name: {{ .Values.Name }}
data:
  myvalue: "Hello World"
EOF

apiVersion: v1
kind: ConfigMap
metadata:
  name: SomeConfig
data:
  myvalue: "Hello World"

Values Files

Each -f can be overridden by more user-supplied values files, which can in turn be overridden by --set parameters.

Values files are plain YAML files. Let’s edit values.yaml and then edit our ConfigMap template.

Built-in Objects

TODO

Template Functions and Pipelines

TODO

Flow Control

TODO

Named Templates

TODO