switchyard/policy/
types.rs1use std::path::PathBuf;
2
3#[derive(Clone, Copy, Debug)]
5pub enum RiskLevel {
6 Stop,
7 Warn,
8 Allow,
9}
10
11#[derive(Clone, Copy, Debug, Default)]
13pub enum ExdevPolicy {
14 #[default]
15 Fail,
16 DegradedFallback,
17}
18
19#[derive(Clone, Copy, Debug)]
21pub enum LockingPolicy {
22 Required,
23 Optional,
24}
25
26#[derive(Clone, Copy, Debug)]
28pub enum PreservationPolicy {
29 Off,
30 RequireBasic,
31}
32
33#[derive(Clone, Copy, Debug, PartialEq, Eq)]
35pub enum SourceTrustPolicy {
36 RequireTrusted,
37 WarnOnUntrusted,
38 AllowUntrusted,
39}
40
41#[derive(Clone, Copy, Debug)]
43pub enum SmokePolicy {
44 Off,
45 Require { auto_rollback: bool },
46}
47
48#[derive(Clone, Debug, Default)]
50pub struct Scope {
51 pub allow_roots: Vec<PathBuf>,
52 pub forbid_paths: Vec<PathBuf>,
53}
54
55#[derive(Debug, Copy, Clone, Default)]
57pub struct Rescue {
58 pub require: bool,
59 pub exec_check: bool,
60 pub min_count: usize,
61}
62
63#[derive(Debug, Copy, Clone)]
65pub struct Risks {
66 pub suid_sgid: RiskLevel,
67 pub hardlinks: RiskLevel,
68 pub source_trust: SourceTrustPolicy,
69 pub ownership_strict: bool,
70}
71
72impl Default for Risks {
73 fn default() -> Self {
74 Self {
75 suid_sgid: RiskLevel::Stop,
76 hardlinks: RiskLevel::Stop,
77 source_trust: SourceTrustPolicy::RequireTrusted,
78 ownership_strict: false,
79 }
80 }
81}
82
83#[derive(Debug, Copy, Clone)]
85pub struct Durability {
86 pub backup_durability: bool,
87 pub sidecar_integrity: bool,
88 pub preservation: PreservationPolicy,
89}
90
91impl Default for Durability {
92 fn default() -> Self {
93 Self {
94 backup_durability: true,
95 sidecar_integrity: true,
96 preservation: PreservationPolicy::Off,
97 }
98 }
99}
100
101#[derive(Clone, Debug, Default)]
103pub struct ApplyFlow {
104 pub exdev: ExdevPolicy,
105 pub override_preflight: bool,
106 pub best_effort_restore: bool,
107 pub extra_mount_checks: Vec<PathBuf>,
108 pub capture_restore_snapshot: bool,
109}
110
111#[derive(Debug, Copy, Clone)]
113pub struct Governance {
114 pub locking: LockingPolicy,
115 pub smoke: SmokePolicy,
116 pub allow_unlocked_commit: bool,
117}
118
119impl Default for Governance {
120 fn default() -> Self {
121 Self {
122 locking: LockingPolicy::Optional,
123 smoke: SmokePolicy::Off,
124 allow_unlocked_commit: true,
125 }
126 }
127}
128
129#[derive(Clone, Debug, Default)]
131pub struct Backup {
132 pub tag: String,
133}