Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Fixes #898: Adds error handling to catch unrecognized keys in the glo…
Browse files Browse the repository at this point in the history
…bal configuration file and report them as errors during the parsing process
  • Loading branch information
Tom McSweeney committed May 4, 2016
1 parent e332eab commit 636b9fd
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions control/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ func (c *Config) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(v, c.Plugins); err != nil {
return err
}
default:
return fmt.Errorf("Unrecognized key '%v' in global config file while parsing 'control'", k)
}
}
return nil
Expand Down
2 changes: 2 additions & 0 deletions mgmt/rest/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ func (c *Config) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(v, &(c.RestAuthPassword)); err != nil {
return fmt.Errorf("%v (while parsing 'restapi::rest_auth_password')", err)
}
default:
return fmt.Errorf("Unrecognized key '%v' in global config file while parsing 'restapi'", k)
}
}
return nil
Expand Down
2 changes: 2 additions & 0 deletions mgmt/tribe/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ func (c *Config) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(v, &(c.Seed)); err != nil {
return fmt.Errorf("%v (while parsing 'tribe::seed')", err)
}
default:
return fmt.Errorf("Unrecognized key '%v' in global config file while parsing 'tribe'", k)
}
}
return nil
Expand Down
2 changes: 2 additions & 0 deletions scheduler/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ func (c *Config) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(v, &(c.WorkManagerPoolSize)); err != nil {
return fmt.Errorf("%v (while parsing 'scheduler::work_manager_pool_size')", err)
}
default:
return fmt.Errorf("Unrecognized key '%v' in global config file while parsing 'scheduler'", k)
}
}
return nil
Expand Down
2 changes: 2 additions & 0 deletions snapd.go
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,8 @@ func (c *Config) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(v, c.Tribe); err != nil {
return err
}
default:
return fmt.Errorf("Unrecognized key '%v' in global config file", k)
}
}
return nil
Expand Down

0 comments on commit 636b9fd

Please sign in to comment.