Skip to main content

canic_core/api/
component_deployment.rs

1//! Module: api::component_deployment
2//!
3//! Responsibility: expose the current runtime's protected Component deployment context.
4//! Does not own: context validation, persistence, authorization, or deployment planning.
5//! Boundary: application policy reads the exact value retained during managed initialization.
6
7use crate::{
8    InternalError,
9    dto::{component_deployment::ProtectedComponentDeployment, error::Error},
10    ids::FleetServiceId,
11    ops::storage::{StorageOpsError, fleet_activation::FleetActivationOps},
12};
13
14///
15/// ComponentDeploymentApi
16///
17/// Local read-only access to immutable Component deployment policy.
18///
19
20pub struct ComponentDeploymentApi;
21
22impl ComponentDeploymentApi {
23    /// Return this Component tree's protected deployment context.
24    pub fn current() -> Result<ProtectedComponentDeployment, Error> {
25        FleetActivationOps::component_deployment()
26            .map_err(StorageOpsError::from)
27            .map_err(InternalError::from)
28            .map_err(Into::into)
29    }
30
31    /// Require this active Component tree to be the exact Authority for one Fleet service.
32    pub fn require_service_authority(service: &FleetServiceId) -> Result<(), Error> {
33        crate::workflow::component_runtime::require_service_authority(service).map_err(Into::into)
34    }
35}