mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
f2614f2107
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
29 lines
787 B
Go
29 lines
787 B
Go
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)
|
|
}
|
|
|
|
// 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)
|
|
}
|