IsReady returns whether the composed resource is ready.
(_ context.Context, o ConditionedObject, rc ...v1beta1.ReadinessCheck)
| 39 | |
| 40 | // IsReady returns whether the composed resource is ready. |
| 41 | func IsReady(_ context.Context, o ConditionedObject, rc ...v1beta1.ReadinessCheck) (bool, error) { |
| 42 | // We don't have API server defaulting, so we default here. |
| 43 | if len(rc) == 0 { |
| 44 | return resource.IsConditionTrue(o.GetCondition(xpv1.TypeReady)), nil |
| 45 | } |
| 46 | |
| 47 | for i := range rc { |
| 48 | ready, err := RunReadinessCheck(rc[i], o) |
| 49 | if err != nil { |
| 50 | return false, errors.Wrapf(err, errFmtRunCheck, i) |
| 51 | } |
| 52 | if !ready { |
| 53 | return false, nil |
| 54 | } |
| 55 | } |
| 56 | return true, nil |
| 57 | } |
| 58 | |
| 59 | // RunReadinessCheck runs the readiness check against the supplied object. |
| 60 | func RunReadinessCheck(c v1beta1.ReadinessCheck, o ConditionedObject) (bool, error) { //nolint:gocyclo // just a switch |