IsReady checks if a Deployment is ready
(deployment appsv1.Deployment)
| 32 | |
| 33 | // IsReady checks if a Deployment is ready |
| 34 | func IsReady(deployment appsv1.Deployment) bool { |
| 35 | // If the deployment has been scaled down to 0 replicas, we consider it ready |
| 36 | if deployment.Status.Replicas == 0 && *deployment.Spec.Replicas == 0 { |
| 37 | return true |
| 38 | } |
| 39 | |
| 40 | if deployment.Status.ObservedGeneration < deployment.Generation || |
| 41 | deployment.Status.UpdatedReplicas < deployment.Status.Replicas || |
| 42 | deployment.Status.AvailableReplicas < deployment.Status.Replicas || |
| 43 | deployment.Status.ReadyReplicas < deployment.Status.Replicas { |
| 44 | return false |
| 45 | } |
| 46 | |
| 47 | if deployment.Status.Conditions == nil { |
| 48 | return false |
| 49 | } |
| 50 | for _, condition := range deployment.Status.Conditions { |
| 51 | if condition.Type == appsv1.DeploymentAvailable && condition.Status != "True" { |
| 52 | return false |
| 53 | } |
| 54 | if condition.Type == appsv1.DeploymentProgressing && condition.Status != "True" { |
| 55 | return false |
| 56 | } |
| 57 | } |
| 58 | return true |
| 59 | } |
| 60 | |
| 61 | // WaitForReady waits for a Deployment to be ready |
| 62 | func WaitForReady( |
no outgoing calls
no test coverage detected