feat: add approval step

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2026-03-15 19:46:33 +01:00
parent 533b738692
commit 7eb6ae7cbb
41 changed files with 7886 additions and 1724 deletions

View File

@@ -247,6 +247,10 @@ pub enum PolicyConfig {
target_environment: String,
branch_pattern: String,
},
Approval {
target_environment: String,
required_approvals: i32,
},
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -267,6 +271,24 @@ pub struct PolicyEvaluation {
pub policy_type: String,
pub passed: bool,
pub reason: String,
#[serde(default)]
pub approval_state: Option<ApprovalState>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApprovalState {
pub required_approvals: i32,
pub current_approvals: i32,
pub decisions: Vec<ApprovalDecisionEntry>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApprovalDecisionEntry {
pub user_id: String,
pub username: String,
pub decision: String,
pub decided_at: String,
pub comment: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -567,6 +589,45 @@ pub trait ForestPlatform: Send + Sync {
channel: &str,
enabled: bool,
) -> Result<(), PlatformError>;
async fn evaluate_policies(
&self,
access_token: &str,
organisation: &str,
project: &str,
target_environment: &str,
release_intent_id: Option<&str>,
) -> Result<Vec<PolicyEvaluation>, PlatformError>;
async fn approve_release(
&self,
access_token: &str,
organisation: &str,
project: &str,
release_intent_id: &str,
target_environment: &str,
comment: Option<&str>,
force_bypass: bool,
) -> Result<ApprovalState, PlatformError>;
async fn reject_release(
&self,
access_token: &str,
organisation: &str,
project: &str,
release_intent_id: &str,
target_environment: &str,
comment: Option<&str>,
) -> Result<ApprovalState, PlatformError>;
async fn get_approval_state(
&self,
access_token: &str,
organisation: &str,
project: &str,
release_intent_id: &str,
target_environment: &str,
) -> Result<ApprovalState, PlatformError>;
}
#[cfg(test)]