-
Notifications
You must be signed in to change notification settings - Fork 72
/
operator_types.go
88 lines (75 loc) · 2.77 KB
/
operator_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
package v1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// OperatorSpec defines the desired state of Operator
type OperatorSpec struct{}
// OperatorStatus defines the observed state of an Operator and its components
type OperatorStatus struct {
// Components describes resources that compose the operator.
// +optional
Components *Components `json:"components,omitempty"`
}
// ConditionType codifies a condition's type.
type ConditionType string
// Condition represent the latest available observations of an component's state.
type Condition struct {
// Type of condition.
Type ConditionType `json:"type"`
// Status of the condition, one of True, False, Unknown.
Status corev1.ConditionStatus `json:"status"`
// The reason for the condition's last transition.
// +optional
Reason string `json:"reason,omitempty"`
// A human readable message indicating details about the transition.
// +optional
Message string `json:"message,omitempty"`
// Last time the condition was probed
// +optional
LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"`
// Last time the condition transitioned from one status to another.
// +optional
LastTransitionTime *metav1.Time `json:"lastTransitionTime,omitempty"`
}
// Components tracks the resources that compose an operator.
type Components struct {
// LabelSelector is a label query over a set of resources used to select the operator's components
LabelSelector *metav1.LabelSelector `json:"labelSelector"`
// Refs are a set of references to the operator's component resources, selected with LabelSelector.
// +optional
Refs []RichReference `json:"refs,omitempty"`
}
// RichReference is a reference to a resource, enriched with its status conditions.
type RichReference struct {
*corev1.ObjectReference `json:",inline"`
// Conditions represents the latest state of the component.
// +optional
// +patchMergeKey=type
// +patchStrategy=merge
Conditions []Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
}
// +genclient
// +genclient:nonNamespaced
// +kubebuilder:object:root=true
// +kubebuilder:storageversion
// +kubebuilder:resource:categories=olm,scope=Cluster
// +kubebuilder:subresource:status
// Operator represents a cluster operator.
type Operator struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec OperatorSpec `json:"spec,omitempty"`
Status OperatorStatus `json:"status,omitempty"`
}
// +genclient:nonNamespaced
// +kubebuilder:object:root=true
// OperatorList contains a list of Operators.
type OperatorList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Operator `json:"items"`
}
func init() {
SchemeBuilder.Register(&Operator{}, &OperatorList{})
}