code: func findNextInitContainerToRun(pod *v1.Pod, podStatus *kubecontainer.PodStatus) (status *kubecontainer.ContainerStatus, next *v1.Container, done bool) {
  	if len(pod.Spec.InitContainers) == 0 {
  		return nil, nil, true
  	}
  
  	// If there are failed containers, return the status of the last failed one.
  	for i := len(pod.Spec.InitContainers) - 1; i >= 0; i-- {
  		container := &pod.Spec.InitContainers[i]
  		status := podStatus.FindContainerStatusByName(container.Name)
  		if status != nil && isInitContainerFailed(status) {
  			return status, container, false
  		}
  	}
  
  	// There are no failed containers now.
  	for i := len(pod.Spec.InitContainers) - 1; i >= 0; i-- {
  		container := &pod.Spec.InitContainers[i]
  		status := podStatus.FindContainerStatusByName(container.Name)
  		if status == nil {
  			continue
  		}
  
  		// container is still running, return not done.
  		if status.State == kubecontainer.ContainerStateRunning {
  			return nil, nil, false
  		}
  
  		if status.State == kubecontainer.ContainerStateExited {
  			// all init containers successful
  			if i == (len(pod.Spec.InitContainers) - 1) {
  				return nil, nil, true
  			}
  
  			// all containers up to i successful, go to i+1
  			return nil, &pod.Spec.InitContainers[i+1], false
  		}
  	}
  
  	return nil, &pod.Spec.InitContainers[0], false
  }
docs: // findNextInitContainerToRun returns the status of the last failed container, the
  // index of next init container to start, or done if there are no further init containers.
  // Status is only returned if an init container is failed, in which case next will
  // point to the current container.