tpl

command module
v0.0.0-...-0a03743 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2016 License: MIT Imports: 13 Imported by: 0

README

tpl

A small utility that transforms templates to text.

The idea is to have a bare-bone confd alternative, that follows the unix philosophy: "Do One Thing and Do It Well".

In other words -> It just transforms template files to text, and spits the output to stdout.

pongo2 templating language was selected because it's familiar and powerful.

why

I needed a small binary that can consume dynamic data from different sources.

confd is awesome, but it does much more than just transform templates.

plus, many times specific filters are missing and I needed a way to add new filters easily.

how

# pipe your template
$ echo 'Hello {{ "NAME" | getenv }}.' | bin/tpl
# or get it from a file
$ bin/tpl /path/to/template/file
configuration

some filters might require a config file. tpl will default to tpl.yml, and if it doesn't exit - will ignore it.

example configuration:

kv:
   url: "localhost:2379"
   type: "etcd" # etcd | consul | zk | boltdb
   bucket: mybucket
   connection-timeout: 10
   persistent-connection: true
  • currently, only kv filter requires a config file.

examples

Elasticsearch Dockerfile

what if you want to create several Dockerfile(s) for different Elasticsearch versions, and even specific plugins?

FROM elasticsearch:{{"VERSION" | getenv:"latest" }}
MAINTAINER Oded odedlaz@example.com

{% if "PLUGINS" | getenv:"" != "" %}
# install all the plugins
{% for plugin in "PLUGINS" | getenv | stringsplit:"," %}
RUN usr/share/elasticsearch/bin/plugin install {{ plugin }}
{% endfor %}
{% endif %}

now run it!

# without any arguments
$ bin/tpl /path/to/Dockerfile.tpl
FROM elasticsearch:latest
MAINTAINER Oded odedlaz@example.com

# with VERSION env variable
$ VERSION="1.7" bin/tpl /path/to/Dockerfile.tpl
FROM elasticsearch:1.7
MAINTAINER Oded odedlaz@example.com

# with the kopf and marvel plugins
$ VERSION="1.7" PLUGINS="kopf,marvel" bin/tpl /path/to/Dockerfile.tpl
FROM elasticsearch:1.7
MAINTAINER Oded odedlaz@example.com

# install all the plugins
RUN usr/share/elasticsearch/bin/plugin install kopf
RUN usr/share/elasticsearch/bin/plugin install marvel

how to build

# build
make build

don't forget to go-get!

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
os
cat
kv

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL