Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
burrow
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hang Yu
burrow
Commits
903a2488
Unverified
Commit
903a2488
authored
8 years ago
by
Benjamin Bollen
Browse files
Options
Downloads
Patches
Plain Diff
Better shield subtree extraction from configuration to avoid Viper panic
parent
716f28eb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
consensus/tendermint/config.go
+7
-1
7 additions, 1 deletion
consensus/tendermint/config.go
consensus/tendermint/tendermint.go
+3
-0
3 additions, 0 deletions
consensus/tendermint/tendermint.go
core/config.go
+8
-1
8 additions, 1 deletion
core/config.go
with
18 additions
and
2 deletions
consensus/tendermint/config.go
+
7
−
1
View file @
903a2488
...
...
@@ -144,7 +144,13 @@ func (tmintConfig *TendermintConfig) GetMapString(key string) map[string]string
}
func
(
tmintConfig
*
TendermintConfig
)
GetConfig
(
key
string
)
tendermintConfig
.
Config
{
return
&
TendermintConfig
{
// TODO: [ben] log out a warning as this indicates a potentially breaking code
// change from Tendermints side
if
!
tmintConfig
.
subTree
.
IsSet
(
key
)
{
return
&
TendermintConfig
{
subTree
:
viper
.
New
(),
}}
return
&
TendermintConfig
{
subTree
:
tmintConfig
.
subTree
.
Sub
(
key
),
}
}
...
...
This diff is collapsed.
Click to expand it.
consensus/tendermint/tendermint.go
+
3
−
0
View file @
903a2488
...
...
@@ -62,6 +62,9 @@ func NewTendermintNode(moduleConfig *config.ModuleConfig,
// to be written in tendermint's root directory.
// NOTE: [ben] as elsewhere Sub panics if config file does not have this
// subtree. To shield in go-routine, or PR to viper.
if
!
moduleConfig
.
Config
.
IsSet
(
"confighuration"
)
{
return
nil
,
fmt
.
Errorf
(
"Failed to extract Tendermint configuration subtree."
)
}
tendermintConfigViper
:=
moduleConfig
.
Config
.
Sub
(
"configuration"
)
if
tendermintConfigViper
==
nil
{
return
nil
,
...
...
This diff is collapsed.
Click to expand it.
core/config.go
+
8
−
1
View file @
903a2488
...
...
@@ -71,6 +71,10 @@ func loadModuleConfig(do *definitions.Do, module string) (*config.ModuleConfig,
// TODO: [ben] Viper internally panics if `moduleName` contains an unallowed
// character (eg, a dash). Either this needs to be wrapped in a go-routine
// and recovered from or a PR to viper is needed to address this bug.
if
!
do
.
Config
.
IsSet
(
moduleName
)
{
return
nil
,
fmt
.
Errorf
(
"Failed to read configuration section for %s"
,
moduleName
)
}
subConfig
:=
do
.
Config
.
Sub
(
moduleName
)
if
subConfig
==
nil
{
return
nil
,
...
...
@@ -93,7 +97,10 @@ func loadModuleConfig(do *definitions.Do, module string) (*config.ModuleConfig,
// LoadServerModuleConfig wraps specifically for the servers run by core
func
LoadServerConfig
(
do
*
definitions
.
Do
)
(
*
server
.
ServerConfig
,
error
)
{
// load configuration subtree for servers
subConfig
:=
do
.
Config
.
Sub
(
"servers"
)
if
!
do
.
Config
.
IsSet
(
"servers"
)
{
return
nil
,
fmt
.
Errorf
(
"Failed to read configuration section for servers"
)
}
subConfig
:=
do
.
Config
.
Sub
(
"servers"
)
if
subConfig
==
nil
{
return
nil
,
fmt
.
Errorf
(
"Failed to read configuration section for servers"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment