canic_host/deployment_truth/model/promotion/source/
mod.rs1use super::super::VerifiedPostconditionV1;
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
8pub enum ArtifactTransportV1 {
9 LocalCli,
10 WasmStore,
11 DirectAgent,
12}
13
14impl ArtifactTransportV1 {
15 #[must_use]
16 pub const fn label(self) -> &'static str {
17 match self {
18 Self::LocalCli => "LocalCli",
19 Self::WasmStore => "WasmStore",
20 Self::DirectAgent => "DirectAgent",
21 }
22 }
23}
24
25#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
29pub struct StagingReceiptV1 {
30 pub schema_version: u32,
31 pub role: String,
32 pub artifact_identity: String,
33 pub transport: ArtifactTransportV1,
34 pub wasm_store_locator: Option<String>,
35 pub prepared_chunk_hashes: Vec<String>,
36 pub published_chunk_count: usize,
37 pub verified_postcondition: VerifiedPostconditionV1,
38}
39
40#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
44pub struct RoleArtifactSourceV1 {
45 pub role: String,
46 pub kind: RoleArtifactSourceKindV1,
47 pub locator: Option<String>,
48 pub previous_receipt_kind: Option<PreviousArtifactReceiptKindV1>,
49 pub previous_receipt_lineage_digest: Option<String>,
50 pub expected_wasm_sha256: Option<String>,
51 pub expected_wasm_gz_sha256: Option<String>,
52 pub expected_candid_sha256: Option<String>,
53 pub expected_canonical_embedded_config_sha256: Option<String>,
54}
55
56#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
60pub struct RolePromotionInputV1 {
61 pub role: String,
62 pub promotion_level: PromotionArtifactLevelV1,
63 pub source: RoleArtifactSourceV1,
64 pub require_byte_identical_wasm: bool,
65 pub require_target_embedded_config: bool,
66 pub target_store_has_artifact: Option<bool>,
67}
68
69#[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
73pub enum PromotionArtifactLevelV1 {
74 SealedWasm,
75 SourceBuild,
76}
77
78impl PromotionArtifactLevelV1 {
79 #[must_use]
80 pub const fn label(self) -> &'static str {
81 match self {
82 Self::SealedWasm => "SealedWasm",
83 Self::SourceBuild => "SourceBuild",
84 }
85 }
86}
87
88#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
92pub enum PromotionReadinessStatusV1 {
93 Ready,
94 Blocked,
95}
96
97impl PromotionReadinessStatusV1 {
98 #[must_use]
99 pub const fn label(self) -> &'static str {
100 match self {
101 Self::Ready => "ready",
102 Self::Blocked => "blocked",
103 }
104 }
105
106 #[must_use]
107 pub const fn variant_label(self) -> &'static str {
108 match self {
109 Self::Ready => "Ready",
110 Self::Blocked => "Blocked",
111 }
112 }
113}
114
115#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
119pub enum RoleArtifactSourceKindV1 {
120 WorkspacePackage,
121 PublishedPackage,
122 LocalWasm,
123 LocalWasmGz,
124 PreviousReceiptArtifact,
125 CanonicalWasmStoreDefault,
126}
127
128impl RoleArtifactSourceKindV1 {
129 #[must_use]
130 pub const fn label(self) -> &'static str {
131 match self {
132 Self::WorkspacePackage => "WorkspacePackage",
133 Self::PublishedPackage => "PublishedPackage",
134 Self::LocalWasm => "LocalWasm",
135 Self::LocalWasmGz => "LocalWasmGz",
136 Self::PreviousReceiptArtifact => "PreviousReceiptArtifact",
137 Self::CanonicalWasmStoreDefault => "CanonicalWasmStoreDefault",
138 }
139 }
140}
141
142#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)]
146pub enum PreviousArtifactReceiptKindV1 {
147 DeploymentReceipt,
148 StagingReceipt,
149}
150
151#[cfg(test)]
152mod tests {
153 use super::*;
154
155 #[test]
156 fn artifact_transport_owns_text_labels() {
157 assert_eq!(ArtifactTransportV1::LocalCli.label(), "LocalCli");
158 assert_eq!(ArtifactTransportV1::WasmStore.label(), "WasmStore");
159 assert_eq!(ArtifactTransportV1::DirectAgent.label(), "DirectAgent");
160 }
161
162 #[test]
163 fn promotion_artifact_level_owns_text_labels() {
164 assert_eq!(PromotionArtifactLevelV1::SealedWasm.label(), "SealedWasm");
165 assert_eq!(PromotionArtifactLevelV1::SourceBuild.label(), "SourceBuild");
166 }
167
168 #[test]
169 fn promotion_readiness_status_owns_text_labels() {
170 assert_eq!(PromotionReadinessStatusV1::Ready.label(), "ready");
171 assert_eq!(PromotionReadinessStatusV1::Blocked.label(), "blocked");
172 assert_eq!(PromotionReadinessStatusV1::Ready.variant_label(), "Ready");
173 assert_eq!(
174 PromotionReadinessStatusV1::Blocked.variant_label(),
175 "Blocked"
176 );
177 }
178
179 #[test]
180 fn role_artifact_source_kind_owns_text_labels() {
181 assert_eq!(
182 RoleArtifactSourceKindV1::WorkspacePackage.label(),
183 "WorkspacePackage"
184 );
185 assert_eq!(
186 RoleArtifactSourceKindV1::PublishedPackage.label(),
187 "PublishedPackage"
188 );
189 assert_eq!(RoleArtifactSourceKindV1::LocalWasm.label(), "LocalWasm");
190 assert_eq!(RoleArtifactSourceKindV1::LocalWasmGz.label(), "LocalWasmGz");
191 assert_eq!(
192 RoleArtifactSourceKindV1::PreviousReceiptArtifact.label(),
193 "PreviousReceiptArtifact"
194 );
195 assert_eq!(
196 RoleArtifactSourceKindV1::CanonicalWasmStoreDefault.label(),
197 "CanonicalWasmStoreDefault"
198 );
199 }
200}