From cd924f552270da4efc687deb193052747f3563ab Mon Sep 17 00:00:00 2001 From: Manuel de Brito Fontes Date: Sat, 4 Mar 2017 17:21:19 -0300 Subject: [PATCH] Avoid duplication of ReadConfig function --- controllers/nginx/pkg/cmd/controller/nginx.go | 22 +------------------ 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/controllers/nginx/pkg/cmd/controller/nginx.go b/controllers/nginx/pkg/cmd/controller/nginx.go index 3c798bb1b..9d12f3b08 100644 --- a/controllers/nginx/pkg/cmd/controller/nginx.go +++ b/controllers/nginx/pkg/cmd/controller/nginx.go @@ -29,7 +29,6 @@ import ( "time" "github.com/golang/glog" - "github.com/mitchellh/mapstructure" "github.com/spf13/pflag" "k8s.io/kubernetes/pkg/api" @@ -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