This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow config options in file as yaml mappings
Replaces the `ff` package with a custom implementation that uses Viper to parse the config file and sets the values for the `flag.Flag`s. By design the ff package doesn't allow flag subsets or nested maps inside the config yaml and all config options must be explicitely defined as `flag.Flag`. This limits the ability to specify more dynamic config options like lists or maps of user defined rules (Ex: metric rollups). Viper provides the flexibility we require for parsing the config file, and unmarshaling directly into more complex datastructures. To define how to unmarshal a subtree of the configuration into a datastructure via unmarshalRule. An unmarshalRule for the dataset config was added as: ``` withUnmarshalRules( []unmarshalRule{{"startup.dataset", &dataset.Config}} ) ``` Given a config file that contains the subtree: ``` startup: dataset: metrics: ... traces: ... ``` The subtree `startup.dataset` will be unmarshal into `&dataset.Config` by Viper using the github.com/mitchellh/mapstructure package. Viper can access a nested field by passing a `.` delimited path of keys. This change also allows us to format our configuration files to use yaml mappings instead of long key names with `.`, thus maintaining backwards compatibility: ``` web.listen-address: localhost:9201 web.auth.password: my-password web.auth.username: promscale ``` Can be rewritten as: ``` web: listen-address: localhost:9201 auth: password: my-password username: promscale ```
- Loading branch information
1 parent
22b5792
commit e08049e
Showing
9 changed files
with
471 additions
and
69 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
Oops, something went wrong.