def performUpdate()

in app/services/kubernetes.scala [77:96]


  def performUpdate(deployment:Deployment, to:DockerImage):Future[Either[LightweightError, Deployment]] =
    extractContainers(deployment) match {
      case Some((containers, initContainers))=>
        val updatedContainers = updateContainersList(containers, to)
        val updatedInitContainers = updateContainersList(initContainers, to)

        if(updatedContainers==containers) {
          logger.error(s"Can't update ${deployment.metadata.name} to $to: no matching containers to update")
          Future(Left(ConflictError.fromDeployment(deployment, to)))
        }
        //if there were no updates to be made to init containers, then `updatedInitContainers`==`initContainers` so there is no change here.
        val updatedTemplateSpec = deployment.spec.flatMap(_.template.spec).map(_.copy(containers=updatedContainers, initContainers=updatedInitContainers))
        val updatedTemplate = deployment.spec.map(_.template).map(_.copy(spec=updatedTemplateSpec))
        val updatedDeloymentSpec = deployment.spec.map(_.copy(template = updatedTemplate.get))
        val updatedDeployment = deployment.copy(spec=updatedDeloymentSpec)
        logger.debug(s"Updated deployment is $updatedDeployment")
        (k8s update[Deployment] updatedDeployment).map(Right.apply)
      case None=>
        Future(Left(GenericError("Deployment is misconfigured, there was nothing to update")))
    }