@@ -17,6 +17,7 @@ limitations under the License.
17
17
package v1
18
18
19
19
import (
20
+ core "k8s.io/api/core/v1"
20
21
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21
22
)
22
23
@@ -34,18 +35,6 @@ const (
34
35
ConditionRequestDenied = "Denied"
35
36
)
36
37
37
- type ConditionStatus string
38
-
39
- // These are valid condition statuses. "ConditionTrue" means a resource is in the condition.
40
- // "ConditionFalse" means a resource is not in the condition. "ConditionUnknown" means kubernetes
41
- // can't decide if a resource is in the condition or not. In the future, we could add other
42
- // intermediate conditions, e.g. ConditionDegraded.
43
- const (
44
- ConditionTrue ConditionStatus = "True"
45
- ConditionFalse ConditionStatus = "False"
46
- ConditionUnknown ConditionStatus = "Unknown"
47
- )
48
-
49
38
type Condition struct {
50
39
// Type of condition in CamelCase or in foo.example.com/CamelCase.
51
40
// Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be
@@ -54,7 +43,7 @@ type Condition struct {
54
43
Type string `json:"type" protobuf:"bytes,1,opt,name=type"`
55
44
// Status of the condition, one of True, False, Unknown.
56
45
// +required
57
- Status ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status"`
46
+ Status core. ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status"`
58
47
// If set, this represents the .metadata.generation that the condition was set based upon.
59
48
// For instance, if .metadata.generation is currently 12, but the .status.condition[x].observedGeneration is 9, the condition is out of date
60
49
// with respect to the current state of the instance.
@@ -76,9 +65,9 @@ type Condition struct {
76
65
}
77
66
78
67
func NewCondition (reason string , message string , generation int64 , conditionStatus ... bool ) Condition {
79
- cs := ConditionTrue
68
+ cs := core . ConditionTrue
80
69
if len (conditionStatus ) > 0 && ! conditionStatus [0 ] {
81
- cs = ConditionFalse
70
+ cs = core . ConditionFalse
82
71
}
83
72
84
73
return Condition {
@@ -150,7 +139,7 @@ func RemoveCondition(conditions []Condition, condType string) []Condition {
150
139
// It returns "false" if the desired condition is not in "true" state or is not in the condition list.
151
140
func IsConditionTrue (conditions []Condition , condType string ) bool {
152
141
for i := range conditions {
153
- if conditions [i ].Type == condType && conditions [i ].Status == ConditionTrue {
142
+ if conditions [i ].Type == condType && conditions [i ].Status == core . ConditionTrue {
154
143
return true
155
144
}
156
145
}
@@ -161,7 +150,7 @@ func IsConditionTrue(conditions []Condition, condType string) bool {
161
150
// It returns "false" if the desired condition is not in "false" state or is not in the condition list.
162
151
func IsConditionFalse (conditions []Condition , condType string ) bool {
163
152
for i := range conditions {
164
- if conditions [i ].Type == condType && conditions [i ].Status == ConditionFalse {
153
+ if conditions [i ].Type == condType && conditions [i ].Status == core . ConditionFalse {
165
154
return true
166
155
}
167
156
}
0 commit comments