providers/os: Add ability to read environment variables

This commit is contained in:
Sasha Koshka 2024-12-05 22:22:25 -05:00
parent 68200e66d6
commit 541f2f0620

View File

@ -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