From 18791a4e6e08de406e9c1e257cc4be2a85f29eea Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Mon, 30 Sep 2024 11:16:28 -0400 Subject: feat(config): Allow avoiding reading default config file (#2227) Signed-off-by: Dave Henderson --- env/env.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'env') diff --git a/env/env.go b/env/env.go index 598361bf..16e121fc 100644 --- a/env/env.go +++ b/env/env.go @@ -20,3 +20,13 @@ func ExpandEnv(s string) string { fsys := datafs.WrapWdFS(osfs.NewFS()) return datafs.ExpandEnvFsys(fsys, s) } + +// LookupEnv - retrieves the value of the environment variable named by the key. +// If the variable is unset, but the same variable ending in `_FILE` is set, the +// referenced file will be read into the value. If the key is not set, the +// second return value will be false. +// Otherwise the provided default (or an emptry string) is returned. +func LookupEnv(key string) (string, bool) { + fsys := datafs.WrapWdFS(osfs.NewFS()) + return datafs.LookupEnvFsys(fsys, key) +} -- cgit v1.2.3