Skip to content

Commit

Permalink
Avoid duplication of ReadConfig function
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Mar 4, 2017
1 parent 1473f64 commit cd924f5
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions controllers/nginx/pkg/cmd/controller/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
"time"

"github.com/golang/glog"
"github.com/mitchellh/mapstructure"
"github.com/spf13/pflag"

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

return n.backendDefaults()
}

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
return ngx_template.ReadConfig(n.configmap.Data).Backend
}

// isReloadRequired check if the new configuration file is different
Expand Down

0 comments on commit cd924f5

Please sign in to comment.