2323package v1alpha
2424
2525import (
26+ "github.com/arangodb/kube-arangodb/pkg/util"
2627 "github.com/dchest/uniuri"
2728 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2829)
@@ -79,6 +80,18 @@ type Action struct {
7980 Image string `json:"image,omitempty"`
8081}
8182
83+ // Equal compares two Actions
84+ func (a Action ) Equal (other Action ) bool {
85+ return a .ID == other .ID &&
86+ a .Type == other .Type &&
87+ a .MemberID == other .MemberID &&
88+ a .Group == other .Group &&
89+ util .TimeCompareEqual (a .CreationTime , other .CreationTime ) &&
90+ util .TimeCompareEqualPointer (a .StartTime , other .StartTime ) &&
91+ a .Reason == other .Reason &&
92+ a .Image == other .Image
93+ }
94+
8295// NewAction instantiates a new Action.
8396func NewAction (actionType ActionType , group ServerGroup , memberID string , reason ... string ) Action {
8497 a := Action {
@@ -105,3 +118,19 @@ func (a Action) SetImage(image string) Action {
105118// Only 1 action is in progress at a time. The operator will wait for that
106119// action to be completely and then remove the action.
107120type Plan []Action
121+
122+ // Equal compares two Plan
123+ func (p Plan ) Equal (other Plan ) bool {
124+ // For plan the order is relevant!
125+ if len (p ) != len (other ) {
126+ return false
127+ }
128+
129+ for i := 0 ; i < len (p ); i ++ {
130+ if ! p [i ].Equal (other [i ]) {
131+ return false
132+ }
133+ }
134+
135+ return true
136+ }
0 commit comments