From 541f2f06209ef3ebd82b22cb538552db996c577c Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 5 Dec 2024 22:22:25 -0500 Subject: [PATCH] providers/os: Add ability to read environment variables --- providers/os/os.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/providers/os/os.go b/providers/os/os.go index 2a2293b..859a421 100644 --- a/providers/os/os.go +++ b/providers/os/os.go @@ -27,6 +27,7 @@ type Provider struct { // FuncMap fulfills the step.FuncProvider interface. func (this *Provider) FuncMap () template.FuncMap { return template.FuncMap { + "env": funcEnv, "fileExists": funcFileExists, "statFile": funcStatFile, "readFile": funcReadFile, @@ -37,6 +38,10 @@ func (this *Provider) FuncMap () template.FuncMap { } } +func funcEnv (name string) string { + return os.Getenv(name) +} + func funcFileExists (name string) (bool) { _, err := os.Stat(name) return err == nil