backend: let ParseConfig return a Config pointer
In order to change the backend initialization in `global.go` to be able to generically call cfg.ApplyEnvironment() for supported backends, the `interface{}` returned by `ParseConfig` must contain a pointer to the configuration. An alternative would be to use reflection to convert the type from `interface{}(Config)` to `interface{}(*Config)` (from value to pointer type). However, this would just complicate the type mess further.
This commit is contained in:
parent
25a0be7f26
commit
f903db492c
26 changed files with 165 additions and 146 deletions
|
@ -27,12 +27,12 @@ func init() {
|
|||
}
|
||||
|
||||
// ParseConfig parses a local backend config.
|
||||
func ParseConfig(s string) (Config, error) {
|
||||
func ParseConfig(s string) (*Config, error) {
|
||||
if !strings.HasPrefix(s, "local:") {
|
||||
return Config{}, errors.New(`invalid format, prefix "local" not found`)
|
||||
return nil, errors.New(`invalid format, prefix "local" not found`)
|
||||
}
|
||||
|
||||
cfg := NewConfig()
|
||||
cfg.Path = s[6:]
|
||||
return cfg, nil
|
||||
return &cfg, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue