-
Notifications
You must be signed in to change notification settings - Fork 73
Break PKS Loop #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Break PKS Loop #277
Changes from 1 commit
22a1b47
5987fa0
9428447
f4db022
f1b44fa
d5a54a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,31 @@ type Condition struct { | |
// Each type is allowed only once. | ||
type ConditionList []Condition | ||
|
||
// Equal checks for equality | ||
func (cl ConditionList) Equal(other ConditionList) bool { | ||
if len(cl) != len(other) { | ||
return false | ||
} | ||
|
||
for i := 0; i < len(cl); i++ { | ||
if !cl[i].Equal(other[i]) { | ||
return false | ||
} | ||
} | ||
|
||
return true | ||
} | ||
|
||
// Equal checks for equality | ||
func (c Condition) Equal(other Condition) bool { | ||
return c.Type == other.Type && | ||
c.Status == other.Status && | ||
c.LastUpdateTime.Time.Sub(other.LastUpdateTime.Time).Seconds() < 2 && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a function for time comparison. Also make sure we do not have to take the absolute value. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a test to make sure. |
||
c.LastTransitionTime.Time.Sub(other.LastTransitionTime.Time).Seconds() < 2 && | ||
c.Reason == other.Reason && | ||
c.Message == other.Message | ||
} | ||
|
||
// IsTrue return true when a condition with given type exists and its status is `True`. | ||
func (list ConditionList) IsTrue(conditionType ConditionType) bool { | ||
c, found := list.Get(conditionType) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,10 @@ | |
|
||
package v1alpha | ||
|
||
import ( | ||
"reflect" | ||
) | ||
|
||
// DeploymentStatus contains the status part of a Cluster resource. | ||
type DeploymentStatus struct { | ||
// Phase holds the current lifetime phase of the deployment | ||
|
@@ -57,3 +61,18 @@ type DeploymentStatus struct { | |
// detect changes in secret values. | ||
SecretHashes *SecretHashes `json:"secret-hashes,omitempty"` | ||
} | ||
|
||
// Equal checks for equality | ||
func (ds *DeploymentStatus) Equal(other DeploymentStatus) bool { | ||
return ds.Phase == other.Phase && | ||
ds.Reason == other.Reason && | ||
ds.ServiceName == other.ServiceName && | ||
ds.SyncServiceName == other.SyncServiceName && | ||
reflect.DeepEqual(ds.Images, other.Images) && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Get rid of DeepEqual altogether round here. |
||
reflect.DeepEqual(ds.CurrentImage, other.CurrentImage) && | ||
ds.Members.Equal(other.Members) && | ||
ds.Conditions.Equal(other.Conditions) && | ||
reflect.DeepEqual(ds.Plan, other.Plan) && | ||
reflect.DeepEqual(ds.AcceptedSpec, other.AcceptedSpec) && | ||
reflect.DeepEqual(ds.SecretHashes, other.SecretHashes) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might have to ignore the order.