Golang library for managing configuration data from environment variables
by kelseyhightowerGo
Last 12 weeks · 0 commits
2 of 6 standards met
Summary required only one lowercase char after the uppercase letter in the second group, causing plural acronyms like or to split incorrectly (e.g. → + → ) Changed to so the second group must have 2+ lowercase chars, preserving plural acronyms as a single token Acronym+word combos like or still split correctly since their second group has multiple lowercase chars Example Before: required After: requires ✓ Test plan [x] Added split_words:"true"\`SpecificationENV_CONFIG_MULTI_WORD_IDS_WITH_AUTO_SPLITdefault_table.txtdefault_list.txtcustom.txtfault.txtgo test ./...`)
This is most useful for generic "wrapper" types that add behavior to a contained value. These kinds of wrappers can be useful for configuration values: A wrapper for sensitive values with protections against printing or logging. A wrapper integrating with a scheme for dynamic configuration changes. The desirable behavior for a wrapper containing a value of type T is for the envconfig facilities to apply for decoding the contained value. Achieving this behavior today requires duplicating much of the logic in in a custom method on the wrapper, in order to handle all the various types of values that might be contained. Instead, this commit introduces support for arbitrary Set(value T) methods by first decoding into a new T and then calling the Set method.
Closes #130 Summary Adds built-in support for the Docker/Kubernetes secrets convention. When an environment variable is unset or empty, envconfig also looks for a companion variable with a suffix (e.g. ). If set, that value is treated as a filesystem path; the file contents are read and used as the configuration value after trailing newlines are trimmed. Non-empty environment variables take precedence over Missing/unreadable files return an error is satisfied when the value comes from a file treats known companions as allowed Existing / API is unchanged (always-on, no new options) This differs from #210, which only exposes a custom hook for applications to implement themselves. Built-in support matches the convention used by Postgres, Redis, and similar images and what was requested in #130. Example Test plan [x] Unit tests with temp files covering: basic read and trailing newline trim env takes precedence over empty env falls back to required field via missing file error alt () name with default when neither env nor file is set allows [x] Full suite:
Repository: kelseyhightower/envconfig. Description: Golang library for managing configuration data from environment variables Stars: 5460, Forks: 393. Primary language: Go. Languages: Go (100%). License: MIT. Latest release: v1.4.0 (7y ago). Open PRs: 30, open issues: 27. Last activity: 1y ago. Community health: 42%. Top contributors: kelseyhightower, teepark, dan9186, andrei-m, dbainbri-ciena, mark-adams, FranGM, AlekSi, aybabtme, relistan and others.