Avoid duplication of ReadConfig function
This commit is contained in:
parent
1473f64fb0
commit
cd924f5522
1 changed files with 1 additions and 21 deletions
|
@ -29,7 +29,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/mitchellh/mapstructure"
|
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
|
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
|
@ -186,26 +185,7 @@ func (n NGINXController) BackendDefaults() defaults.Backend {
|
||||||
return d.Backend
|
return d.Backend
|
||||||
}
|
}
|
||||||
|
|
||||||
return n.backendDefaults()
|
return ngx_template.ReadConfig(n.configmap.Data).Backend
|
||||||
}
|
|
||||||
|
|
||||||
func (n *NGINXController) backendDefaults() defaults.Backend {
|
|
||||||
d := config.NewDefault()
|
|
||||||
config := &mapstructure.DecoderConfig{
|
|
||||||
Metadata: nil,
|
|
||||||
WeaklyTypedInput: true,
|
|
||||||
Result: &d,
|
|
||||||
TagName: "json",
|
|
||||||
}
|
|
||||||
decoder, err := mapstructure.NewDecoder(config)
|
|
||||||
if err != nil {
|
|
||||||
glog.Warningf("unexpected error merging defaults: %v", err)
|
|
||||||
}
|
|
||||||
err = decoder.Decode(n.configmap.Data)
|
|
||||||
if err != nil {
|
|
||||||
glog.Warningf("unexpected error decoding: %v", err)
|
|
||||||
}
|
|
||||||
return d.Backend
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// isReloadRequired check if the new configuration file is different
|
// isReloadRequired check if the new configuration file is different
|
||||||
|
|
Loading…
Reference in a new issue