MCPcopy Index your code
hub / github.com/crossplane-contrib/function-patch-and-transform / ValidateEnvironment

Function ValidateEnvironment

validate.go:92–114  ·  view source on GitHub ↗

ValidateEnvironment validates (patches to and from) the Environment.

(e *v1beta1.Environment)

Source from the content-addressed store, hash-verified

90
91// ValidateEnvironment validates (patches to and from) the Environment.
92func ValidateEnvironment(e *v1beta1.Environment) *field.Error {
93 if e == nil {
94 return nil
95 }
96 for i, p := range e.Patches {
97 switch p.GetType() { //nolint:exhaustive // Only target valid patches according the API spec
98 case
99 v1beta1.PatchTypeFromCompositeFieldPath,
100 v1beta1.PatchTypeToCompositeFieldPath,
101 v1beta1.PatchTypeCombineFromComposite,
102 v1beta1.PatchTypeCombineToComposite,
103 v1beta1.PatchTypeFromEnvironmentFieldPath,
104 v1beta1.PatchTypeToEnvironmentFieldPath:
105 default:
106 return field.Invalid(field.NewPath("patches").Index(i).Key("type"), p.GetType(), "invalid environment patch type")
107 }
108
109 if err := ValidatePatch(&p); err != nil {
110 return WrapFieldError(err, field.NewPath("patches").Index(i))
111 }
112 }
113 return nil
114}
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

Callers 1

ValidateResourcesFunction · 0.85

Calls 3

ValidatePatchFunction · 0.85
WrapFieldErrorFunction · 0.85
GetTypeMethod · 0.65

Tested by

no test coverage detected