rustploy 0.1.19

Rustploy PaaS daemon — lightweight self-hosted deployment platform
//! `Command`s de IaC (manifesto e pacote de serviço): só roteia para `features::iac`.

use crate::bootstrap::state::AppState;
use shared::{Command, Response as RpResponse};

pub async fn dispatch(state: AppState, cmd: Command) -> RpResponse {
    match cmd {
        Command::ServiceExportPlan { service_id } => {
            crate::features::iac::service_export::plan(state.iac_ctx(), service_id).await
        }
        Command::ServiceExport {
            service_id,
            include_values,
            project_env_keys,
        } => {
            crate::features::iac::service_export::export(
                state.iac_ctx(),
                service_id,
                include_values,
                project_env_keys,
            )
            .await
        }
        Command::ServiceImport(req) => {
            crate::features::iac::service_import::handle(state.iac_ctx(), req).await
        }
        Command::ManifestApply {
            manifests,
            prune,
            deploy,
        } => {
            crate::features::iac::manifest_apply::handle(state.iac_ctx(), manifests, prune, deploy)
                .await
        }
        Command::ManifestExport { project_id } => {
            crate::features::iac::manifest_export::handle(state.iac_ctx(), project_id).await
        }
        Command::ManifestExportAll => {
            crate::features::iac::manifest_export_all::handle(state.iac_ctx()).await
        }
        Command::ManifestImport {
            yaml,
            dotenv,
            prune,
            deploy,
        } => {
            crate::features::iac::manifest_import::handle(
                state.iac_ctx(),
                yaml,
                dotenv,
                prune,
                deploy,
            )
            .await
        }
        _ => RpResponse::err("NotImplemented", "command not yet implemented"),
    }
}