ValidateEnvironment validates (patches to and from) the Environment.
(e *v1beta1.Environment)
| 90 | |
| 91 | // ValidateEnvironment validates (patches to and from) the Environment. |
| 92 | func 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. |
| 117 | func ValidateReadinessCheck(r v1beta1.ReadinessCheck) *field.Error { //nolint:gocyclo // This function is not that complex, just a switch |
no test coverage detected