(
mut environment: Environment,
infra_ctx: &InfrastructureContext,
abort: &dyn Abort,
)
| 306 | } |
| 307 | |
| 308 | pub fn deploy_environment( |
| 309 | mut environment: Environment, |
| 310 | infra_ctx: &InfrastructureContext, |
| 311 | abort: &dyn Abort, |
| 312 | ) -> Result<(), Box<EngineError>> { |
| 313 | let mut deployed_services: HashSet<Uuid> = HashSet::new(); |
| 314 | let event_details = environment.event_details().clone(); |
| 315 | let run_deploy = || -> Result<(), Box<EngineError>> { |
| 316 | // Build apps |
| 317 | if abort.status().should_cancel() { |
| 318 | return Err(Box::new(EngineError::new_task_cancellation_requested(event_details))); |
| 319 | } |
| 320 | |
| 321 | let logger = Arc::new(infra_ctx.kubernetes().logger().clone_dyn()); |
| 322 | |
| 323 | // INFO (qov-1569) Trigger external secrets deployments only for a Create environment action |
| 324 | // Note: it doesn't mean that the underlying services are in Deploy state, but it prevents from |
| 325 | // deploying external secrets on Pause / Restart / Delete env actions. |
| 326 | if environment.action == service::Action::Create { |
| 327 | handle_service_external_secrets(&mut environment, infra_ctx, abort)?; |
| 328 | } |
| 329 | |
| 330 | let services_to_build: Vec<&mut dyn Service> = environment |
| 331 | .applications |
| 332 | .iter_mut() |
| 333 | .map(|app| app.as_service_mut()) |
| 334 | .chain(environment.jobs.iter_mut().map(|job| job.as_service_mut())) |
| 335 | .chain( |
| 336 | environment |
| 337 | .terraform_services |
| 338 | .iter_mut() |
| 339 | .map(|terraform_service| terraform_service.as_service_mut()), |
| 340 | ) |
| 341 | .collect(); |
| 342 | Self::build_and_push_services( |
| 343 | environment.long_id, |
| 344 | environment.project_long_id, |
| 345 | services_to_build, |
| 346 | &DeploymentOption { |
| 347 | force_build: false, |
| 348 | force_push: false, |
| 349 | }, |
| 350 | infra_ctx, |
| 351 | environment.max_parallel_build as usize, |
| 352 | |srv: &dyn Service| EnvLogger::new(srv, EnvironmentStep::Build, logger.clone()), |
| 353 | abort, |
| 354 | )?; |
| 355 | |
| 356 | if abort.status().should_cancel() { |
| 357 | return Err(Box::new(EngineError::new_task_cancellation_requested(event_details))); |
| 358 | } |
| 359 | let mut env_deployment = EnvironmentDeployment::new(infra_ctx, &environment, abort, logger.clone())?; |
| 360 | let deployment_ret = match environment.action { |
| 361 | service::Action::Create => env_deployment.on_create(), |
| 362 | service::Action::Pause => env_deployment.on_pause(), |
| 363 | service::Action::Delete => env_deployment.on_delete(), |
| 364 | service::Action::Restart => env_deployment.on_restart(), |
| 365 | }; |
nothing calls this directly
no test coverage detected