-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sources/env): key prefix option, use settings struct to create s…
…ource
- Loading branch information
Showing
6 changed files
with
48 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package env | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/qdm12/gosettings" | ||
) | ||
|
||
// Settings contains settings for the environment variable source. | ||
type Settings struct { | ||
// Environ is a slice of "key=value" pairs which defaults | ||
// to the returned value of os.Environ(). | ||
// Element without a '=' sign are ignored. | ||
// All environment variable keys read are eventually | ||
// transformed using the KeyTransform method. | ||
// It defaults to the empty string. | ||
Environ []string | ||
// KeyPrefix is a prefix to add to all keys read from | ||
// the environment. It is usually the program name to avoid | ||
// conflict with other programs in the environment. | ||
// It defaults to the empty string. | ||
KeyPrefix string | ||
} | ||
|
||
func (s *Settings) setDefaults() { | ||
s.Environ = gosettings.DefaultSlice(s.Environ, os.Environ()) | ||
} |