@@ -16,8 +16,6 @@ limitations under the License.
16
16
package v1alpha2
17
17
18
18
import (
19
- "fmt"
20
-
21
19
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22
20
)
23
21
@@ -152,7 +150,7 @@ type HierarchyConfigurationStatus struct {
152
150
Children []string `json:"children,omitempty"`
153
151
154
152
// Conditions describes the errors, if any.
155
- Conditions []Condition `json:"conditions,omitempty"`
153
+ Conditions []metav1. Condition `json:"conditions,omitempty"`
156
154
}
157
155
158
156
// +kubebuilder:object:root=true
@@ -176,94 +174,6 @@ type MetaKVP struct {
176
174
Value string `json:"value"`
177
175
}
178
176
179
- // metav1.Condition is introduced in k8s.io/apimachinery v0.20.0-alpha.1 and we
180
- // don't want to take a dependency on it yet, thus we copied the below struct from
181
- // https://github.com/kubernetes/apimachinery/blob/master/pkg/apis/meta/v1/types.go:
182
-
183
- // Condition contains details for one aspect of the current state of this API Resource.
184
- // ---
185
- // This struct is intended for direct use as an array at the field path .status.conditions. For example,
186
- // type FooStatus struct{
187
- // // Represents the observations of a foo's current state.
188
- // // Known .status.conditions.type are: "Available", "Progressing", and "Degraded"
189
- // // +patchMergeKey=type
190
- // // +patchStrategy=merge
191
- // // +listType=map
192
- // // +listMapKey=type
193
- // Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
194
- //
195
- // // other fields
196
- // }
197
- type Condition struct {
198
- // type of condition in CamelCase or in foo.example.com/CamelCase.
199
- // ---
200
- // Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be
201
- // useful (see .node.status.conditions), the ability to deconflict is important.
202
- // The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)
203
- // +required
204
- // +kubebuilder:validation:Required
205
- // +kubebuilder:validation:Pattern=`^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$`
206
- // +kubebuilder:validation:MaxLength=316
207
- Type string `json:"type" protobuf:"bytes,1,opt,name=type"`
208
- // status of the condition, one of True, False, Unknown.
209
- // +required
210
- // +kubebuilder:validation:Required
211
- // +kubebuilder:validation:Enum=True;False;Unknown
212
- Status metav1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status"`
213
- // observedGeneration represents the .metadata.generation that the condition was set based upon.
214
- // For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
215
- // with respect to the current state of the instance.
216
- // +optional
217
- // +kubebuilder:validation:Minimum=0
218
- ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,3,opt,name=observedGeneration"`
219
- // lastTransitionTime is the last time the condition transitioned from one status to another.
220
- // This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
221
- // +required
222
- // +kubebuilder:validation:Required
223
- // +kubebuilder:validation:Type=string
224
- // +kubebuilder:validation:Format=date-time
225
- LastTransitionTime metav1.Time `json:"lastTransitionTime" protobuf:"bytes,4,opt,name=lastTransitionTime"`
226
- // reason contains a programmatic identifier indicating the reason for the condition's last transition.
227
- // Producers of specific condition types may define expected values and meanings for this field,
228
- // and whether the values are considered a guaranteed API.
229
- // The value should be a CamelCase string.
230
- // This field may not be empty.
231
- // +required
232
- // +kubebuilder:validation:Required
233
- // +kubebuilder:validation:MaxLength=1024
234
- // +kubebuilder:validation:MinLength=1
235
- // +kubebuilder:validation:Pattern=`^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$`
236
- Reason string `json:"reason" protobuf:"bytes,5,opt,name=reason"`
237
- // message is a human readable message indicating details about the transition.
238
- // This may be an empty string.
239
- // +required
240
- // +kubebuilder:validation:Required
241
- // +kubebuilder:validation:MaxLength=32768
242
- Message string `json:"message" protobuf:"bytes,6,opt,name=message"`
243
- }
244
-
245
- // NewCondition fills some required field with default values for schema
246
- // validation, e.g. Status and LastTransitionTime.
247
- func NewCondition (tp , reason , msg string ) Condition {
248
- return Condition {
249
- Type : tp ,
250
- Status : "True" ,
251
- // Set time as an obviously wrong value 1970-01-01T00:00:00Z since we
252
- // overwrite conditions every time.
253
- LastTransitionTime : metav1 .Unix (0 , 0 ),
254
- Reason : reason ,
255
- Message : msg ,
256
- }
257
- }
258
-
259
- func (c Condition ) String () string {
260
- msg := c .Message
261
- if len (msg ) > 100 {
262
- msg = msg [:100 ] + "..."
263
- }
264
- return fmt .Sprintf ("%s (%s): %s" , c .Type , c .Reason , msg )
265
- }
266
-
267
177
func init () {
268
178
SchemeBuilder .Register (& HierarchyConfiguration {}, & HierarchyConfigurationList {})
269
179
}
0 commit comments