mirror of
https://github.com/pomerium/pomerium.git
synced 2025-05-12 16:47:41 +02:00
fix deep copy of config (#1089)
This commit is contained in:
parent
d3a7ee38be
commit
02b4e4b619
3 changed files with 6 additions and 16 deletions
|
@ -1,12 +1,9 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"sync"
|
||||
|
||||
"github.com/fsnotify/fsnotify"
|
||||
"github.com/mitchellh/copystructure"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// Config holds pomerium configuration options.
|
||||
|
@ -14,15 +11,13 @@ type Config struct {
|
|||
Options *Options
|
||||
}
|
||||
|
||||
// Clone creates a deep clone of the config.
|
||||
// Clone creates a clone of the config.
|
||||
func (cfg *Config) Clone() *Config {
|
||||
return copystructure.Must(copystructure.Config{
|
||||
Copiers: map[reflect.Type]copystructure.CopierFunc{
|
||||
reflect.TypeOf((*viper.Viper)(nil)): func(i interface{}) (interface{}, error) {
|
||||
return i, nil
|
||||
},
|
||||
},
|
||||
}.Copy(cfg)).(*Config)
|
||||
newOptions := new(Options)
|
||||
*newOptions = *cfg.Options
|
||||
return &Config{
|
||||
Options: newOptions,
|
||||
}
|
||||
}
|
||||
|
||||
// A ChangeListener is called when configuration changes.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue