Skip to content

Commit

Permalink
feat: add datasource NewEnvSource
Browse files Browse the repository at this point in the history
  • Loading branch information
whatwewant committed Apr 21, 2024
1 parent 0df5200 commit fd103d7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions datasource/env.go
Original file line number Diff line number Diff line change
@@ -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(key string) any {
if key == "" {
return nil
}

value := os.Getenv(key)
if value == "" {
return nil
}

return value
}

0 comments on commit fd103d7

Please sign in to comment.