<!-- The default pull request template is for types feat, fix, or refactor. For other templates, add one of the following parameters to the url: - template=docs.md - template=other.md --> ## Description Closes: #5540 <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [x] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
31 lines
1.3 KiB
Go
31 lines
1.3 KiB
Go
/*
|
|
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. `InterceptConfigsPreRunHandler` takes
|
|
two parameters to set/update a custom template to create custom `app.toml`.
|
|
If these parameters are empty, the server then creates a default template
|
|
provided by the SDK.
|
|
*/
|
|
package server
|