Skip to main content

systemprompt_sync/deploy/
progress.rs

1//! Progress seam between the deploy pipeline and its presentation layer.
2//!
3//! The orchestrator emits a [`DeployEvent`] at every step boundary and asks
4//! the caller to resolve each [`DeployPrompt`]; implementations decide how
5//! (or whether) to render and answer them. Events carry borrowed data, so no
6//! rendering state lives in the pipeline.
7//!
8//! Copyright (c) systemprompt.io — Business Source License 1.1.
9//! See <https://systemprompt.io> for licensing details.
10
11use std::path::Path;
12
13use crate::error::SyncResult;
14use crate::files::SyncDiffResult;
15use crate::result::SyncOperationResult;
16
17pub trait DeployProgress: Send + Sync {
18    fn event(&self, event: &DeployEvent<'_>);
19    fn confirm(&self, prompt: &DeployPrompt) -> SyncResult<bool>;
20}
21
22#[derive(Debug, Clone, Copy)]
23pub enum DeployEvent<'a> {
24    PreSyncSkippedByFlag,
25    PreSyncStarted,
26    PreSyncDeclined,
27    SyncDryRunStarted,
28    SyncDryRunFinished(&'a SyncOperationResult),
29    SyncErrors(&'a [String]),
30    SyncDownloadStarted,
31    SyncDownloadFinished,
32    SyncBackupStarted,
33    SyncBackupFinished(&'a Path),
34    SyncDiff(&'a SyncDiffResult),
35    SyncAlreadyClean,
36    SyncCancelled,
37    SyncApplied {
38        count: usize,
39    },
40    ArtifactsResolved {
41        tenant_name: &'a str,
42        binary: &'a Path,
43        dockerfile: &'a Path,
44    },
45    RegistryAuthStarted,
46    RegistryAuthFinished,
47    ImageResolved {
48        image: &'a str,
49    },
50    BuildStarted,
51    BuildFinished,
52    PushSkipped,
53    PushStarted,
54    PushFinished,
55    SecretsPhaseStarted,
56    SecretsFileMissing,
57    SecretsSyncStarted,
58    SecretsSynced {
59        count: usize,
60    },
61    CredentialsSyncStarted,
62    CredentialsSynced {
63        count: usize,
64    },
65    ProfilePathConfigured,
66    DeployStarted,
67    Deployed {
68        status: &'a str,
69        app_url: Option<&'a str>,
70    },
71}
72
73#[derive(Debug, Clone, Copy)]
74pub enum DeployPrompt {
75    PreSync,
76    ApplyChanges { count: usize },
77}