-
Notifications
You must be signed in to change notification settings - Fork 6
/
status_types.go
176 lines (161 loc) · 5.89 KB
/
status_types.go
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
package v1alpha1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const (
ClusterVersionLimit = 5
)
const (
StatusClusterStatusFalse = "False"
StatusClusterStatusTrue = "True"
)
const (
StatusClusterTypeCreated = "Created"
StatusClusterTypeCreating = "Creating"
)
const (
StatusClusterTypeDeleted = "Deleted"
StatusClusterTypeDeleting = "Deleting"
)
const (
StatusClusterTypeUpdated = "Updated"
StatusClusterTypeUpdating = "Updating"
)
// +k8s:openapi-gen=true
type StatusCluster struct {
// +kubebuilder:validation:Optional
// +nullable
// Conditions is a list of status information expressing the current
// conditional state of a workload cluster. This may reflect the status of the
// workload cluster being updating or being up to date.
Conditions []StatusClusterCondition `json:"conditions,omitempty"`
// +kubebuilder:validation:Optional
// +nullable
Network StatusClusterNetwork `json:"network"`
// +kubebuilder:validation:Optional
// +nullable
// Nodes is a list of workload cluster node information reflecting the current
// state of the workload cluster nodes.
Nodes []StatusClusterNode `json:"nodes,omitempty"`
// +kubebuilder:validation:Optional
// +nullable
// Resources is a list of arbitrary conditions of operatorkit resource
// implementations.
Resources []StatusClusterResource `json:"resources,omitempty"`
// +kubebuilder:validation:Optional
// +nullable
Scaling StatusClusterScaling `json:"scaling"`
// +kubebuilder:validation:Optional
// +nullable
// Versions is a list that acts like a historical track record of versions a
// workload cluster went through. A version is only added to the list as soon as
// the workload cluster successfully migrated to the version added here.
Versions []StatusClusterVersion `json:"versions,omitempty"`
}
// StatusClusterCondition expresses the conditions in which a workload cluster may
// is.
// +k8s:openapi-gen=true
type StatusClusterCondition struct {
// +kubebuilder:validation:Optional
// +nullable
// LastTransitionTime is the last time the condition transitioned from one
// status to another.
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
// +kubebuilder:validation:Optional
// Status may be True, False or Unknown.
Status string `json:"status"`
// +kubebuilder:validation:Optional
// Type may be Creating, Created, Scaling, Scaled, Draining, Drained,
// Updating, Updated, Deleting, Deleted.
Type string `json:"type"`
}
// StatusClusterNetwork expresses the network segment that is allocated for a
// workload cluster.
// +k8s:openapi-gen=true
type StatusClusterNetwork struct {
// +kubebuilder:validation:Optional
CIDR string `json:"cidr"`
}
// StatusClusterNode holds information about a workload cluster node.
// +k8s:openapi-gen=true
type StatusClusterNode struct {
// +kubebuilder:validation:Optional
// +nullable
// Labels contains the kubernetes labels for corresponding node.
Labels map[string]string `json:"labels,omitempty"`
// +kubebuilder:validation:Optional
// +nullable
// LastTransitionTime is the last time the condition transitioned from one
// status to another.
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
// +kubebuilder:validation:Optional
// Name referrs to a workload cluster node name.
Name string `json:"name"`
// +kubebuilder:validation:Optional
// Version referrs to the version used by the node as mandated by the provider
// operator.
Version string `json:"version"`
}
// Resource is structure holding arbitrary conditions of operatorkit resource
// implementations. Imagine an operator implements an instance resource. This
// resource may operates sequentially but has to operate based on a certain
// system state it manages. So it tracks the status as needed here specific to
// its own implementation and means in order to fulfil its premise.
// +k8s:openapi-gen=true
type StatusClusterResource struct {
// +kubebuilder:validation:Optional
// +nullable
Conditions []StatusClusterResourceCondition `json:"conditions,omitempty"`
// +kubebuilder:validation:Optional
Name string `json:"name"`
}
// StatusClusterResourceCondition expresses the conditions in which an
// operatorkit resource may is.
// +k8s:openapi-gen=true
type StatusClusterResourceCondition struct {
// +kubebuilder:validation:Optional
// +nullable
// LastTransitionTime is the last time the condition transitioned from one
// status to another.
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
// +kubebuilder:validation:Optional
// Status may be True, False or Unknown.
Status string `json:"status"`
// +kubebuilder:validation:Optional
// Type may be anything an operatorkit resource may define.
Type string `json:"type"`
}
// StatusClusterScaling expresses the current status of desired number of
// worker nodes in the workload cluster.
// +k8s:openapi-gen=true
type StatusClusterScaling struct {
// +kubebuilder:validation:Optional
DesiredCapacity int `json:"desiredCapacity"`
}
// StatusClusterVersion expresses the versions in which a workload cluster was and
// may still be.
// +k8s:openapi-gen=true
type StatusClusterVersion struct {
// +kubebuilder:validation:Optional
// +nullable
// TODO date is deprecated due to LastTransitionTime
// This can be removed ones the new properties are properly used in all workload
// clusters.
//
// https://github.com/giantswarm/giantswarm/issues/3988
//
Date metav1.Time `json:"date,omitempty"`
// +kubebuilder:validation:Optional
// +nullable
// LastTransitionTime is the last time the condition transitioned from one
// status to another.
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"`
// +kubebuilder:validation:Optional
// Semver is some semver version, e.g. 1.0.0.
Semver string `json:"semver"`
}
// DeepCopyInto implements the deep copy magic the k8s codegen is not able to
// generate out of the box.
func (in *StatusClusterVersion) DeepCopyInto(out *StatusClusterVersion) {
*out = *in
}