code: func calculateStatus(allRSs []*apps.ReplicaSet, newRS *apps.ReplicaSet, deployment *apps.Deployment) apps.DeploymentStatus {
  	availableReplicas := deploymentutil.GetAvailableReplicaCountForReplicaSets(allRSs)
  	totalReplicas := deploymentutil.GetReplicaCountForReplicaSets(allRSs)
  	unavailableReplicas := totalReplicas - availableReplicas
  	// If unavailableReplicas is negative, then that means the Deployment has more available replicas running than
  	// desired, e.g. whenever it scales down. In such a case we should simply default unavailableReplicas to zero.
  	if unavailableReplicas < 0 {
  		unavailableReplicas = 0
  	}
  
  	status := apps.DeploymentStatus{
  		// TODO: Ensure that if we start retrying status updates, we won't pick up a new Generation value.
  		ObservedGeneration:  deployment.Generation,
  		Replicas:            deploymentutil.GetActualReplicaCountForReplicaSets(allRSs),
  		UpdatedReplicas:     deploymentutil.GetActualReplicaCountForReplicaSets([]*apps.ReplicaSet{newRS}),
  		ReadyReplicas:       deploymentutil.GetReadyReplicaCountForReplicaSets(allRSs),
  		AvailableReplicas:   availableReplicas,
  		UnavailableReplicas: unavailableReplicas,
  		CollisionCount:      deployment.Status.CollisionCount,
  	}
  
  	// Copy conditions one by one so we won't mutate the original object.
  	conditions := deployment.Status.Conditions
  	for i := range conditions {
  		status.Conditions = append(status.Conditions, conditions[i])
  	}
  
  	if availableReplicas >= *(deployment.Spec.Replicas)-deploymentutil.MaxUnavailable(*deployment) {
  		minAvailability := deploymentutil.NewDeploymentCondition(apps.DeploymentAvailable, v1.ConditionTrue, deploymentutil.MinimumReplicasAvailable, "Deployment has minimum availability.")
  		deploymentutil.SetDeploymentCondition(&status, *minAvailability)
  	} else {
  		noMinAvailability := deploymentutil.NewDeploymentCondition(apps.DeploymentAvailable, v1.ConditionFalse, deploymentutil.MinimumReplicasUnavailable, "Deployment does not have minimum availability.")
  		deploymentutil.SetDeploymentCondition(&status, *noMinAvailability)
  	}
  
  	return status
  }
docs: // calculateStatus calculates the latest status for the provided deployment by looking into the provided replica sets.