resources: Simplify the resource Compare functions

This removes one level of indentation and simplifies the code.
This commit is contained in:
James Shubin
2017-05-31 16:42:29 -04:00
parent bd4563b699
commit 6e503cc79b
15 changed files with 373 additions and 332 deletions

View File

@@ -275,22 +275,23 @@ func (obj *NspawnRes) GroupCmp(r Res) bool {
}
// Compare two resources and return if they are equivalent.
func (obj *NspawnRes) Compare(res Res) bool {
switch res.(type) {
case *NspawnRes:
res := res.(*NspawnRes)
if !obj.BaseRes.Compare(res) {
return false
}
if obj.Name != res.Name {
return false
}
if !obj.svc.Compare(res.svc) {
return false
}
default:
func (obj *NspawnRes) Compare(r Res) bool {
// we can only compare NspawnRes to others of the same resource kind
res, ok := r.(*NspawnRes)
if !ok {
return false
}
if !obj.BaseRes.Compare(res) {
return false
}
if obj.Name != res.Name {
return false
}
if !obj.svc.Compare(res.svc) {
return false
}
return true
}