Skip to content

Commit ca1b6be

Browse files
committed
ProgressionProbes
Provides an API which allows custom probe definitions to determine readiness of the CER phases. Objects can be selected for in one of two ways: by GroupKind, or by Label (matchLabels and matchExpressions). They can then be tested via any of: Condition, FieldsEqual, and FieldValue. Condition checks that the object has a condition matching the type and status provided. FieldsEqual uses two provided field paths and checks for equality. FieldValue uses a provided field path and checks that the value is equal to the provided expected value. Signed-off-by: Daniel Franz <dfranz@redhat.com>
1 parent 6f23a79 commit ca1b6be

19 files changed

Lines changed: 1496 additions & 9 deletions

api/v1/clusterextensionrevision_types.go

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ type ClusterExtensionRevisionSpec struct {
106106
// <opcon:experimental>
107107
ProgressDeadlineMinutes int32 `json:"progressDeadlineMinutes,omitempty"`
108108

109+
// +optional
110+
// +kubebuilder:validation:MaxItems=20
111+
ProgressionProbes []ProgressionProbe `json:"progressionProbes,omitempty"`
112+
109113
// collisionProtection specifies the default collision protection strategy for all objects
110114
// in this revision. Individual phases or objects can override this value.
111115
//
@@ -120,6 +124,95 @@ type ClusterExtensionRevisionSpec struct {
120124
CollisionProtection CollisionProtection `json:"collisionProtection,omitempty"`
121125
}
122126

127+
type ProgressionProbe struct {
128+
// +required
129+
Selector ProbeSelector `json:"selector,omitempty"`
130+
131+
// +required
132+
// +kubebuilder:validation:MaxItems=20
133+
Assertions []ProbeAssertion `json:"assertions,omitempty"`
134+
}
135+
136+
// +union
137+
// +kubebuilder:validation:XValidation:rule="self.type == 'GroupKind' ?has(self.groupKind) : !has(self.groupKind)",message="groupKind is required when type is GroupKind, and forbidden otherwise"
138+
// +kubebuilder:validation:XValidation:rule="self.type == 'Label' ?has(self.label) : !has(self.label)",message="label is required when type is Label, and forbidden otherwise"
139+
type ProbeSelector struct {
140+
// +unionDiscriminator
141+
// +kubebuilder:validation:Enum=GroupKind;Label
142+
// +required
143+
SelectorType SelectorType `json:"type,omitempty"`
144+
145+
// +optional
146+
// +unionMember
147+
GroupKind metav1.GroupKind `json:"groupKind,omitempty"`
148+
149+
// +optional
150+
// +unionMember
151+
Label metav1.LabelSelector `json:"label,omitempty"`
152+
}
153+
154+
type SelectorType string
155+
156+
const (
157+
SelectorTypeGroupKind SelectorType = "GroupKind"
158+
SelectorTypeLabel SelectorType = "Label"
159+
)
160+
161+
type ProbeType string
162+
163+
const (
164+
ProbeTypeFieldCondition ProbeType = "Condition"
165+
ProbeTypeFieldEqual ProbeType = "FieldsEqual"
166+
ProbeTypeFieldValue ProbeType = "FieldValue"
167+
)
168+
169+
// +union
170+
// +kubebuilder:validation:XValidation:rule="self.type == 'Condition' ?has(self.condition) : !has(self.condition)",message="condition is required when type is Condition, and forbidden otherwise"
171+
// +kubebuilder:validation:XValidation:rule="self.type == 'FieldsEqual' ?has(self.fieldsEqual) : !has(self.fieldsEqual)",message="fieldsEqual is required when type is FieldsEqual, and forbidden otherwise"
172+
// +kubebuilder:validation:XValidation:rule="self.type == 'FieldValue' ?has(self.fieldValue) : !has(self.fieldValue)",message="fieldValue is required when type is FieldValue, and forbidden otherwise"
173+
type ProbeAssertion struct {
174+
// +unionDiscriminator
175+
// +kubebuilder:validation:Enum=Condition;FieldsEqual;FieldValue
176+
// +required
177+
ProbeType ProbeType `json:"type,omitempty"`
178+
179+
// +unionMember
180+
// +optional
181+
Condition ConditionProbe `json:"condition,omitempty"`
182+
183+
// +unionMember
184+
// +optional
185+
FieldsEqual FieldsEqualProbe `json:"fieldsEqual,omitempty"`
186+
187+
// +unionMember
188+
// +optional
189+
FieldValue FieldValueProbe `json:"fieldValue,omitempty"`
190+
}
191+
192+
type ConditionProbe struct {
193+
// +required
194+
Type string `json:"type,omitempty"`
195+
196+
// +required
197+
Status string `json:"status,omitempty"`
198+
}
199+
200+
type FieldsEqualProbe struct {
201+
// +required
202+
FieldA string `json:"fieldA,omitempty"`
203+
204+
// +required
205+
FieldB string `json:"fieldB,omitempty"`
206+
}
207+
208+
type FieldValueProbe struct {
209+
// +required
210+
FieldPath string `json:"fieldPath,omitempty"`
211+
212+
// +required
213+
Value string `json:"value,omitempty"`
214+
}
215+
123216
// ClusterExtensionRevisionLifecycleState specifies the lifecycle state of the ClusterExtensionRevision.
124217
type ClusterExtensionRevisionLifecycleState string
125218

api/v1/zz_generated.deepcopy.go

Lines changed: 108 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

applyconfigurations/api/v1/clusterextensionrevisionspec.go

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

applyconfigurations/api/v1/conditionprobe.go

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

applyconfigurations/api/v1/fieldsequalprobe.go

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)