forked from cosmos/cosmos-sdk
-
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.
fix: Rework InterceptConfigsPreRunHandler to make sure configuration … (
cosmos#7501) * fix: Rework InterceptConfigsPreRunHandler to make sure configuration is pulled from all Viper sources * docs: Add configuration documentation in a new file
- Loading branch information
1 parent
6e569e1
commit 8384a5a
Showing
3 changed files
with
511 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
The commands from the SDK are defined with `cobra` and configured with the | ||
`viper` package. | ||
This takes place in the `InterceptConfigsPreRunHandler` function. | ||
Since the `viper` package is used for configuration the precedence is dictated | ||
by that package. That is | ||
1. Command line switches | ||
2. Environment variables | ||
3. Files from configuration values | ||
4. Default values | ||
The global configuration instance exposed by the `viper` package is not | ||
used by Cosmos SDK in this function. A new instance of `viper.Viper` is created | ||
and the following is performed. The environmental variable prefix is set | ||
to the current program name. Environmental variables consider the underscore | ||
to be equivalent to the `.` or `-` character. This means that an configuration | ||
value called `rpc.laddr` would be read from an environmental variable called | ||
`MYTOOL_RPC_LADDR` if the current program name is `mytool`. | ||
Running the `InterceptConfigsPreRunHandler` also reads `app.toml` | ||
and `config.toml` from the home directory under the `config` directory. | ||
If `config.toml` or `app.toml` do not exist then those files are created | ||
and populated with default values. | ||
*/ | ||
package server |
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.