From a198cb700e12ecb2d43ad3cc0bc3f655382c4b15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Bergstr=C3=B6m?= Date: Thu, 2 Nov 2017 17:55:42 +0100 Subject: [PATCH] Add env & expandenv template functions Using environment variables is a common practice when deploying docker containers. --- template/template.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/template/template.go b/template/template.go index cb54b8cb63..d1eb5fec43 100644 --- a/template/template.go +++ b/template/template.go @@ -16,6 +16,7 @@ package template import ( "bytes" "net/url" + "os" "path/filepath" "regexp" "sort" @@ -135,6 +136,8 @@ var DefaultFuncs = FuncMap{ re := regexp.MustCompile(pattern) return re.ReplaceAllString(text, repl) }, + "env": func(s string) string { return os.Getenv(s) }, + "expandenv": func(s string) string { return os.ExpandEnv(s) }, } // Pair is a key/value string pair.