From 4d74554300fa7e5e660cc935a92e89f8b71012ea Mon Sep 17 00:00:00 2001 From: Cory Bennett Date: Tue, 3 Oct 2017 18:47:33 -0400 Subject: [PATCH] add `{{env.VARNAME}}` template support to allow use of env vars --- jiracli/templates.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jiracli/templates.go b/jiracli/templates.go index 575184a7..1b64af8f 100644 --- a/jiracli/templates.go +++ b/jiracli/templates.go @@ -65,6 +65,14 @@ func TemplateProcessor() *template.Template { "jira": func() string { return os.Args[0] }, + "env": func() map[string]string { + out := map[string]string{} + for _, env := range os.Environ() { + kv := strings.SplitN(env, "=", 2) + out[kv[0]] = kv[1] + } + return out + }, "toJson": func(content interface{}) (string, error) { bytes, err := json.MarshalIndent(content, "", " ") if err != nil {