Fix equals comparsion returing False if both objects have nil Targets or Services.

This commit is contained in:
Dario Nieuwenhuis 2017-09-14 18:37:27 +02:00
parent 62aa9a43d5
commit 94b28a95d9

View file

@ -149,6 +149,7 @@ func (b1 *Backend) Equal(b2 *Backend) bool {
return false return false
} }
if b1.Service != b2.Service {
if b1.Service == nil || b2.Service == nil { if b1.Service == nil || b2.Service == nil {
return false return false
} }
@ -161,6 +162,7 @@ func (b1 *Backend) Equal(b2 *Backend) bool {
if b1.Service.GetResourceVersion() != b2.Service.GetResourceVersion() { if b1.Service.GetResourceVersion() != b2.Service.GetResourceVersion() {
return false return false
} }
}
if b1.Port != b2.Port { if b1.Port != b2.Port {
return false return false
@ -255,6 +257,7 @@ func (e1 *Endpoint) Equal(e2 *Endpoint) bool {
return false return false
} }
if e1.Target != e2.Target {
if e1.Target == nil || e2.Target == nil { if e1.Target == nil || e2.Target == nil {
return false return false
} }
@ -264,6 +267,7 @@ func (e1 *Endpoint) Equal(e2 *Endpoint) bool {
if e1.Target.ResourceVersion != e2.Target.ResourceVersion { if e1.Target.ResourceVersion != e2.Target.ResourceVersion {
return false return false
} }
}
return true return true
} }
@ -336,6 +340,7 @@ func (l1 *Location) Equal(l2 *Location) bool {
return false return false
} }
if l1.Service != l2.Service {
if l1.Service == nil || l2.Service == nil { if l1.Service == nil || l2.Service == nil {
return false return false
} }
@ -348,6 +353,7 @@ func (l1 *Location) Equal(l2 *Location) bool {
if l1.Service.GetResourceVersion() != l2.Service.GetResourceVersion() { if l1.Service.GetResourceVersion() != l2.Service.GetResourceVersion() {
return false return false
} }
}
if l1.Port.StrVal != l2.Port.StrVal { if l1.Port.StrVal != l2.Port.StrVal {
return false return false
@ -410,6 +416,7 @@ func (ptb1 *SSLPassthroughBackend) Equal(ptb2 *SSLPassthroughBackend) bool {
return false return false
} }
if ptb1.Service != ptb2.Service {
if ptb1.Service == nil || ptb2.Service == nil { if ptb1.Service == nil || ptb2.Service == nil {
return false return false
} }
@ -422,6 +429,7 @@ func (ptb1 *SSLPassthroughBackend) Equal(ptb2 *SSLPassthroughBackend) bool {
if ptb1.Service.GetResourceVersion() != ptb2.Service.GetResourceVersion() { if ptb1.Service.GetResourceVersion() != ptb2.Service.GetResourceVersion() {
return false return false
} }
}
return true return true
} }