MCPcopy Create free account
hub / github.com/crossplane-contrib/function-patch-and-transform / ValidateReadinessCheck

Function ValidateReadinessCheck

validate.go:117–145  ·  view source on GitHub ↗

ValidateReadinessCheck checks if the readiness check is logically valid.

(r v1beta1.ReadinessCheck)

Source from the content-addressed store, hash-verified

115
116// ValidateReadinessCheck checks if the readiness check is logically valid.
117func ValidateReadinessCheck(r v1beta1.ReadinessCheck) *field.Error { //nolint:gocyclo // This function is not that complex, just a switch
118 if !r.Type.IsValid() {
119 return field.Invalid(field.NewPath("type"), string(r.Type), "unknown readiness check type")
120 }
121 switch r.Type {
122 case v1beta1.ReadinessCheckTypeNone:
123 return nil
124 case v1beta1.ReadinessCheckTypeMatchString:
125 if r.MatchString == nil {
126 return field.Required(field.NewPath("matchString"), "cannot be nil for type MatchString")
127 }
128 case v1beta1.ReadinessCheckTypeMatchInteger:
129 if r.MatchInteger == nil {
130 return field.Required(field.NewPath("matchInteger"), "cannot be nil for type MatchInteger")
131 }
132 case v1beta1.ReadinessCheckTypeMatchCondition:
133 if err := ValidateMatchConditionReadinessCheck(r.MatchCondition); err != nil {
134 return WrapFieldError(err, field.NewPath("matchCondition"))
135 }
136 return nil
137 case v1beta1.ReadinessCheckTypeNonEmpty, v1beta1.ReadinessCheckTypeMatchFalse, v1beta1.ReadinessCheckTypeMatchTrue:
138 // No specific validation required.
139 }
140 if r.FieldPath == nil {
141 return field.Required(field.NewPath("fieldPath"), "cannot be empty")
142 }
143
144 return nil
145}
146
147// ValidateMatchConditionReadinessCheck checks if the match condition is
148// logically valid.

Callers 3

ValidateComposedTemplateFunction · 0.85
RunReadinessCheckFunction · 0.85

Calls 3

WrapFieldErrorFunction · 0.85
IsValidMethod · 0.45

Tested by 1