2016-07-26 00:15:08 -07:00
|
|
|
package equality
|
|
|
|
|
|
|
|
import (
|
|
|
|
"reflect"
|
|
|
|
|
|
|
|
"github.com/docker/swarmkit/api"
|
|
|
|
)
|
|
|
|
|
|
|
|
// TasksEqualStable returns true if the tasks are functionaly equal, ignoring status,
|
|
|
|
// version and other superfluous fields.
|
|
|
|
//
|
|
|
|
// This used to decide whether or not to propagate a task update to a controller.
|
|
|
|
func TasksEqualStable(a, b *api.Task) bool {
|
|
|
|
// shallow copy
|
|
|
|
copyA, copyB := *a, *b
|
|
|
|
|
|
|
|
copyA.Status, copyB.Status = api.TaskStatus{}, api.TaskStatus{}
|
|
|
|
copyA.Meta, copyB.Meta = api.Meta{}, api.Meta{}
|
|
|
|
|
|
|
|
return reflect.DeepEqual(©A, ©B)
|
|
|
|
}
|
2016-08-09 11:49:39 -07:00
|
|
|
|
|
|
|
// TaskStatusesEqualStable compares the task status excluding timestamp fields.
|
|
|
|
func TaskStatusesEqualStable(a, b *api.TaskStatus) bool {
|
|
|
|
copyA, copyB := *a, *b
|
|
|
|
|
|
|
|
copyA.Timestamp, copyB.Timestamp = nil, nil
|
|
|
|
return reflect.DeepEqual(©A, ©B)
|
|
|
|
}
|