23
23
package v1alpha
24
24
25
25
import (
26
+ "github.com/arangodb/kube-arangodb/pkg/util"
26
27
"github.com/dchest/uniuri"
27
28
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
28
29
)
@@ -79,6 +80,18 @@ type Action struct {
79
80
Image string `json:"image,omitempty"`
80
81
}
81
82
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
+
82
95
// NewAction instantiates a new Action.
83
96
func NewAction (actionType ActionType , group ServerGroup , memberID string , reason ... string ) Action {
84
97
a := Action {
@@ -105,3 +118,19 @@ func (a Action) SetImage(image string) Action {
105
118
// Only 1 action is in progress at a time. The operator will wait for that
106
119
// action to be completely and then remove the action.
107
120
type 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