You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor env provider into a major breaking version /v2 (#341)
- `providers/env` is now `/providers/env/v2`
- Add new `Opt{}` struct with transform functions that can be passed to the
constructor instead of the old `WithProvider(..)` functions. This allow future
callbacks and options to be added without breaking changes.
- `Opt.TransformFunc` is now a single transformation function for keys and values.
- `Opt.EnvirnFunc` allows the source of environment variables to be plugged
for testing and mocking. It defaults to `os.Environ`.
---------
Co-authored-by: Kailash Nadh <[email protected]>
// If there is a space in the value, split the value into a slice by the space.
276
-
if strings.Contains(v, "") {
277
-
return key, strings.Split(v, "")
278
-
}
279
-
280
-
// Otherwise, return the plain string.
281
-
return key, v
282
-
}), nil)
283
-
```
284
274
285
275
### Reading from an S3 bucket
286
276
@@ -662,7 +652,7 @@ Install with `go get -u github.com/knadh/koanf/providers/$provider`
662
652
| fs | `fs.Provider(f fs.FS, filepath string)` | (**Experimental**) Reads a file from fs.FS and returns the raw bytes to be parsed. The provider requires `go v1.16` or higher. |
| posflag | `posflag.Provider(f *pflag.FlagSet, delim string)` | Takes an `spf13/pflag.FlagSet` (advanced POSIX compatible flags with multiple types) and provides a nested config map based on delim. |
665
-
| env | `env.Provider(prefix, delim string, f func(s string) string)` | Takes an optional prefix to filter env variables by, an optional function that takes and returns a string to transform env variables, and returns a nested config map based on delim. |
655
+
| env/v2 | `env.Provider(prefix, delim string, f func(s string) string)` | Takes an optional prefix to filter env variables by, an optional function that takes and returns a string to transform env variables, and returns a nested config map based on delim. |
666
656
| confmap | `confmap.Provider(mp map[string]interface{}, delim string)` | Takes a premade `map[string]interface{}` conf map. If delim is provided, the keys are assumed to be flattened, thus unflattened using delim. |
667
657
| structs | `structs.Provider(s interface{}, tag string)` | Takes a struct and struct tag. |
0 commit comments