diff --git a/datasource/env.go b/datasource/env.go new file mode 100644 index 0000000..c1a00f5 --- /dev/null +++ b/datasource/env.go @@ -0,0 +1,26 @@ +package datasource + +import "os" + +// envDataSource is a data source that loads data from the environment. +type envDataSource struct { +} + +// NewEnvSource creates a new envDataSource. +func NewEnvSource() DataSource { + return &envDataSource{} +} + +// Get returns the value of the given key. +func (envDataSource) Get(path, key string) any { + if key == "" { + return nil + } + + value := os.Getenv(key) + if value == "" { + return nil + } + + return value +}