Skip to main content

canic_host/deployment_truth/model/promotion/source/
mod.rs

1use super::super::VerifiedPostconditionV1;
2use serde::{Deserialize, Serialize};
3
4///
5/// ArtifactTransportV1
6///
7#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
8pub enum ArtifactTransportV1 {
9    LocalCli,
10    WasmStore,
11    DirectAgent,
12}
13
14///
15/// StagingReceiptV1
16///
17#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
18pub struct StagingReceiptV1 {
19    pub schema_version: u32,
20    pub role: String,
21    pub artifact_identity: String,
22    pub transport: ArtifactTransportV1,
23    pub wasm_store_locator: Option<String>,
24    pub prepared_chunk_hashes: Vec<String>,
25    pub published_chunk_count: usize,
26    pub verified_postcondition: VerifiedPostconditionV1,
27}
28
29///
30/// RoleArtifactSourceV1
31///
32#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
33pub struct RoleArtifactSourceV1 {
34    pub role: String,
35    pub kind: RoleArtifactSourceKindV1,
36    pub locator: Option<String>,
37    pub previous_receipt_kind: Option<PreviousArtifactReceiptKindV1>,
38    pub previous_receipt_lineage_digest: Option<String>,
39    pub expected_wasm_sha256: Option<String>,
40    pub expected_wasm_gz_sha256: Option<String>,
41    pub expected_candid_sha256: Option<String>,
42    pub expected_canonical_embedded_config_sha256: Option<String>,
43}
44
45///
46/// RolePromotionInputV1
47///
48#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
49pub struct RolePromotionInputV1 {
50    pub role: String,
51    pub promotion_level: PromotionArtifactLevelV1,
52    pub source: RoleArtifactSourceV1,
53    pub require_byte_identical_wasm: bool,
54    pub require_target_embedded_config: bool,
55    pub target_store_has_artifact: Option<bool>,
56}
57
58///
59/// PromotionArtifactLevelV1
60///
61#[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
62pub enum PromotionArtifactLevelV1 {
63    SealedWasm,
64    SourceBuild,
65}
66
67///
68/// PromotionReadinessStatusV1
69///
70#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
71pub enum PromotionReadinessStatusV1 {
72    Ready,
73    Blocked,
74}
75
76impl PromotionReadinessStatusV1 {
77    #[must_use]
78    pub const fn label(self) -> &'static str {
79        match self {
80            Self::Ready => "ready",
81            Self::Blocked => "blocked",
82        }
83    }
84}
85
86///
87/// RoleArtifactSourceKindV1
88///
89#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
90pub enum RoleArtifactSourceKindV1 {
91    WorkspacePackage,
92    PublishedPackage,
93    LocalWasm,
94    LocalWasmGz,
95    PreviousReceiptArtifact,
96    CanonicalWasmStoreDefault,
97}
98
99///
100/// PreviousArtifactReceiptKindV1
101///
102#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
103pub enum PreviousArtifactReceiptKindV1 {
104    DeploymentReceipt,
105    StagingReceipt,
106}
107
108#[cfg(test)]
109mod tests {
110    use super::*;
111
112    #[test]
113    fn promotion_readiness_status_owns_text_labels() {
114        assert_eq!(PromotionReadinessStatusV1::Ready.label(), "ready");
115        assert_eq!(PromotionReadinessStatusV1::Blocked.label(), "blocked");
116    }
117}