1use serde::{Deserialize, Serialize};
2
3use crate::types::{DeployTarget, ProjectConfig};
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
7#[serde(rename_all = "snake_case")]
8pub enum DeployMode {
9 Plan,
10 Run,
11 Verify,
12 Promote,
13 Status,
14 History,
15}
16
17#[derive(Debug, Clone, Default, Serialize, Deserialize)]
18pub struct DeployFlags {
19 pub dry_run: bool,
20 pub skip_oci: bool,
21 pub skip_apply: bool,
22 pub skip_rollout: bool,
23 pub skip_health: bool,
24 pub yes: bool,
25 pub json: bool,
26 pub namespace: Option<String>,
27 pub context: Option<String>,
28 pub promote_tag: Option<String>,
29 pub history_limit: usize,
30 pub output: Option<std::path::PathBuf>,
31}
32
33#[derive(Debug, Clone)]
35pub struct DeployContext {
36 pub env: String,
37 pub target: DeployTarget,
38 pub config: ProjectConfig,
39 pub flags: DeployFlags,
40 pub mode: DeployMode,
41}
42
43impl DeployContext {
44 pub fn require_confirmation(&self) -> bool {
45 if self.flags.yes || self.flags.dry_run {
46 return false;
47 }
48 self.config
49 .kubernetes
50 .as_ref()
51 .map(|k| k.require_context_confirmation_for_apply)
52 .unwrap_or(true)
53 }
54}