WaitForReady waits for a Deployment to be ready
( ctx context.Context, crudClient client.Client, deployment *appsv1.Deployment, timeoutSeconds uint, )
| 60 | |
| 61 | // WaitForReady waits for a Deployment to be ready |
| 62 | func WaitForReady( |
| 63 | ctx context.Context, |
| 64 | crudClient client.Client, |
| 65 | deployment *appsv1.Deployment, |
| 66 | timeoutSeconds uint, |
| 67 | ) error { |
| 68 | err := retry.New( |
| 69 | retry.Attempts(timeoutSeconds), |
| 70 | retry.Delay(time.Second), |
| 71 | retry.DelayType(retry.FixedDelay)). |
| 72 | Do( |
| 73 | func() error { |
| 74 | if err := crudClient.Get(ctx, client.ObjectKey{ |
| 75 | Namespace: deployment.Namespace, |
| 76 | Name: deployment.Name, |
| 77 | }, deployment); err != nil { |
| 78 | return err |
| 79 | } |
| 80 | if !IsReady(*deployment) { |
| 81 | return fmt.Errorf( |
| 82 | "deployment not ready. Namespace: %v, Name: %v", |
| 83 | deployment.Namespace, |
| 84 | deployment.Name, |
| 85 | ) |
| 86 | } |
| 87 | return nil |
| 88 | }, |
| 89 | ) |
| 90 | return err |
| 91 | } |