|
| 1 | +package v1alpha1 |
| 2 | + |
| 3 | +import ( |
| 4 | + corev1 "k8s.io/api/core/v1" |
| 5 | + "k8s.io/apimachinery/pkg/api/meta" |
| 6 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 7 | +) |
| 8 | + |
| 9 | +type FlowControl struct { |
| 10 | + Percentage *int `json:"percentage,omitempty"` |
| 11 | + MaxConcurrency *int `json:"maxConcurrency,omitempty"` |
| 12 | +} |
| 13 | + |
| 14 | +// ClusterDrainSpec defines the desired state of ClusterDrain |
| 15 | +type ClusterDrainSpec struct { |
| 16 | + FlowControl FlowControl `json:"flowControl"` |
| 17 | + LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"` |
| 18 | +} |
| 19 | + |
| 20 | +// ClusterDrainStatus defines the observed state of ClusterDrain |
| 21 | +type ClusterDrainStatus struct { |
| 22 | + // Represents the observations of a HealthConvert current state. |
| 23 | + // +patchMergeKey=type |
| 24 | + // +patchStrategy=merge |
| 25 | + // +listType=map |
| 26 | + // +listMapKey=type |
| 27 | + Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` |
| 28 | + Progress []Progress `json:"progress,omitempty"` |
| 29 | +} |
| 30 | + |
| 31 | +type Progress struct { |
| 32 | + Wave int `json:"wave"` |
| 33 | + Percentage int `json:"percentage"` |
| 34 | + Count int `json:"count"` |
| 35 | + Failures []corev1.ObjectReference `json:"failures,omitempty"` |
| 36 | +} |
| 37 | + |
| 38 | +//+kubebuilder:object:root=true |
| 39 | +//+kubebuilder:subresource:status |
| 40 | + |
| 41 | +// ClusterDrain is the Schema for the ClusterDrain object |
| 42 | +type ClusterDrain struct { |
| 43 | + metav1.TypeMeta `json:",inline"` |
| 44 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 45 | + |
| 46 | + Spec ClusterDrainSpec `json:"spec,omitempty"` |
| 47 | + Status ClusterDrainStatus `json:"status,omitempty"` |
| 48 | +} |
| 49 | + |
| 50 | +//+kubebuilder:object:root=true |
| 51 | + |
| 52 | +// ClusterDrainList contains a list of ClusterDrain |
| 53 | +type ClusterDrainList struct { |
| 54 | + metav1.TypeMeta `json:",inline"` |
| 55 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 56 | + Items []ClusterDrain `json:"items"` |
| 57 | +} |
| 58 | + |
| 59 | +func init() { |
| 60 | + SchemeBuilder.Register(&ClusterDrain{}, &ClusterDrainList{}) |
| 61 | +} |
| 62 | + |
| 63 | +func (c *ClusterDrain) SetCondition(condition metav1.Condition) { |
| 64 | + meta.SetStatusCondition(&c.Status.Conditions, condition) |
| 65 | +} |
0 commit comments