Skip to content

Commit 043ee62

Browse files
committed
improve
1 parent 815866a commit 043ee62

3 files changed

Lines changed: 33 additions & 24 deletions

File tree

src/api/data_types/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
33
mod chunking;
44
mod deploy;
5+
mod snapshots;
56

67
pub use self::chunking::*;
78
pub use self::deploy::*;
9+
pub use self::snapshots::*;

src/api/data_types/snapshots.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//! Data types for the snapshots API.
2+
3+
use std::collections::HashMap;
4+
5+
use serde::{Deserialize, Serialize};
6+
7+
/// Response from the create snapshot endpoint.
8+
#[derive(Debug, Deserialize)]
9+
#[serde(rename_all = "camelCase")]
10+
pub struct CreateSnapshotResponse {
11+
pub artifact_id: String,
12+
pub image_count: u64,
13+
}
14+
15+
// Keep in sync with https://github.com/getsentry/sentry/blob/master/src/sentry/preprod/snapshots/manifest.py
16+
/// Manifest describing a set of snapshot images for an app.
17+
#[derive(Debug, Serialize)]
18+
pub struct SnapshotsManifest {
19+
pub app_id: String,
20+
pub images: HashMap<String, ImageMetadata>,
21+
}
22+
23+
// Keep in sync with https://github.com/getsentry/sentry/blob/master/src/sentry/preprod/snapshots/manifest.py
24+
/// Metadata for a single image in a snapshot manifest.
25+
#[derive(Debug, Serialize)]
26+
pub struct ImageMetadata {
27+
pub image_file_name: String,
28+
pub width: u32,
29+
pub height: u32,
30+
}

src/commands/build/snapshots.rs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ use clap::{Arg, ArgMatches, Command};
88
use console::style;
99
use log::{debug, info, warn};
1010
use objectstore_client::{ClientBuilder, ExpirationPolicy, Usecase};
11-
use serde::{Deserialize, Serialize};
1211
use sha2::{Digest as _, Sha256};
1312
use walkdir::WalkDir;
1413

1514
use secrecy::ExposeSecret as _;
1615

17-
use crate::api::Api;
16+
use crate::api::{Api, CreateSnapshotResponse, ImageMetadata, SnapshotsManifest};
1817
use crate::config::{Auth, Config};
1918
use crate::utils::args::ArgExt as _;
2019

@@ -47,28 +46,6 @@ pub fn make_command(command: Command) -> Command {
4746
)
4847
}
4948

50-
#[derive(Deserialize)]
51-
#[serde(rename_all = "camelCase")]
52-
struct CreateSnapshotResponse {
53-
artifact_id: String,
54-
image_count: u64,
55-
}
56-
57-
// Keep in sync with https://github.com/getsentry/sentry/blob/master/src/sentry/preprod/snapshots/manifest.py
58-
#[derive(Serialize)]
59-
struct SnapshotsManifest {
60-
app_id: String,
61-
images: HashMap<String, ImageMetadata>,
62-
}
63-
64-
// Keep in sync with https://github.com/getsentry/sentry/blob/master/src/sentry/preprod/snapshots/manifest.py
65-
#[derive(Serialize)]
66-
struct ImageMetadata {
67-
image_file_name: String,
68-
width: u32,
69-
height: u32,
70-
}
71-
7249
struct ImageInfo {
7350
path: std::path::PathBuf,
7451
relative_path: String,

0 commit comments

Comments
 (0)