Refactoring nginx configuration configmap

This commit is contained in:
Manuel de Brito Fontes 2017-09-07 13:15:36 -03:00
parent 7434c50cdb
commit e57b90636b

View file

@ -465,23 +465,22 @@ Error: %v
// SetConfig sets the configured configmap // SetConfig sets the configured configmap
func (n *NGINXController) SetConfig(cmap *api_v1.ConfigMap) { func (n *NGINXController) SetConfig(cmap *api_v1.ConfigMap) {
n.configmap = cmap n.configmap = cmap
n.isProxyProtocolEnabled = false n.isProxyProtocolEnabled = false
if cmap == nil {
n.backendDefaults = config.NewDefault().Backend m := map[string]string{}
return if cmap != nil {
m = cmap.Data
} }
val, ok := cmap.Data["use-proxy-protocol"] val, ok := m["use-proxy-protocol"]
if ok { if ok {
b, err := strconv.ParseBool(val) b, err := strconv.ParseBool(val)
if err == nil { if err == nil {
n.isProxyProtocolEnabled = b n.isProxyProtocolEnabled = b
return
} }
} }
n.backendDefaults = ngx_template.ReadConfig(n.configmap.Data).Backend n.backendDefaults = ngx_template.ReadConfig(m).Backend
} }
// SetListers sets the configured store listers in the generic ingress controller // SetListers sets the configured store listers in the generic ingress controller