tatara_core/domain/
release.rs1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3use uuid::Uuid;
4
5use super::job::JobSpec;
6
7#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
8#[serde(rename_all = "snake_case")]
9pub enum ReleaseStatus {
10 Pending,
11 Active,
12 Superseded,
13 RolledBack,
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
17pub struct Release {
18 pub id: Uuid,
19 pub name: String,
20 pub flake_ref: String,
21 pub flake_rev: Option<String>,
22 pub job_id: String,
23 pub job_spec_snapshot: Option<JobSpec>,
24 pub version: u64,
25 pub status: ReleaseStatus,
26 pub created_at: DateTime<Utc>,
27}
28
29impl Release {
30 pub fn new(name: String, flake_ref: String, job_id: String) -> Self {
31 Self {
32 id: Uuid::new_v4(),
33 name,
34 flake_ref,
35 flake_rev: None,
36 job_id,
37 job_spec_snapshot: None,
38 version: 1,
39 status: ReleaseStatus::Pending,
40 created_at: Utc::now(),
41 }
42 }
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47pub struct CreateReleaseRequest {
48 pub name: String,
49 pub flake_ref: String,
50 pub job_id: String,
51 #[serde(default)]
52 pub flake_rev: Option<String>,
53}