-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathconditions.go
More file actions
82 lines (69 loc) · 2.02 KB
/
Copy pathconditions.go
File metadata and controls
82 lines (69 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const (
// Degraded is the condition type used to inform state of the operator when
// it has failed with irrecoverable error like permission issues.
// DebugEnabled has the following options:
// Status:
// - True
// - False
// Reason:
// - Failed
Degraded string = "Degraded"
// Ready is the condition type used to inform state of readiness of the
// operator to process istio-csr enabling requests.
// Status:
// - True
// - False
// Reason:
// - Progressing
// - Failed
// - Ready: operand successfully deployed and ready
Ready string = "Ready"
// Progressing indicates whether the operator is actively reconciling
// toward the desired state.
// Status:
// - True: reconciliation is in progress
// - False: reconciliation is idle (succeeded or permanently failed)
Progressing string = "Progressing"
)
const (
ReasonFailed string = "Failed"
ReasonReady string = "Ready"
ReasonInProgress string = "Progressing"
ReasonReconciling string = "Reconciling"
ReasonWaitingForDependencies string = "WaitingForDependencies"
ReasonValidationFailed string = "ValidationFailed"
ReasonMultipleInstancesFound string = "MultipleInstancesFound"
)
func (c *ConditionalStatus) GetCondition(t string) *metav1.Condition {
for i, cond := range c.Conditions {
if cond.Type == t {
return &c.Conditions[i]
}
}
return nil
}
func (c *ConditionalStatus) SetCondition(t string, cs metav1.ConditionStatus, reason, msg string) bool {
condition := c.GetCondition(t)
if condition == nil {
c.Conditions = append(c.Conditions, metav1.Condition{
Type: t,
Status: cs,
LastTransitionTime: metav1.Now(),
Reason: reason,
Message: msg,
})
return true
}
if condition.Status != cs || condition.Reason != reason {
condition.Status = cs
condition.LastTransitionTime = metav1.Now()
condition.Reason = reason
condition.Message = msg
return true
}
return false
}