Skip to content

Commit cd924f5

Browse files
committed
Avoid duplication of ReadConfig function
1 parent 1473f64 commit cd924f5

File tree

1 file changed

+1
-21
lines changed
  • controllers/nginx/pkg/cmd/controller

1 file changed

+1
-21
lines changed

controllers/nginx/pkg/cmd/controller/nginx.go

+1-21
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"time"
3030

3131
"github.com/golang/glog"
32-
"github.com/mitchellh/mapstructure"
3332
"github.com/spf13/pflag"
3433

3534
"k8s.io/kubernetes/pkg/api"
@@ -186,26 +185,7 @@ func (n NGINXController) BackendDefaults() defaults.Backend {
186185
return d.Backend
187186
}
188187

189-
return n.backendDefaults()
190-
}
191-
192-
func (n *NGINXController) backendDefaults() defaults.Backend {
193-
d := config.NewDefault()
194-
config := &mapstructure.DecoderConfig{
195-
Metadata: nil,
196-
WeaklyTypedInput: true,
197-
Result: &d,
198-
TagName: "json",
199-
}
200-
decoder, err := mapstructure.NewDecoder(config)
201-
if err != nil {
202-
glog.Warningf("unexpected error merging defaults: %v", err)
203-
}
204-
err = decoder.Decode(n.configmap.Data)
205-
if err != nil {
206-
glog.Warningf("unexpected error decoding: %v", err)
207-
}
208-
return d.Backend
188+
return ngx_template.ReadConfig(n.configmap.Data).Backend
209189
}
210190

211191
// isReloadRequired check if the new configuration file is different

0 commit comments

Comments
 (0)