Phase 5a: approval queue (request_apply_commit, pending/approve/deny)
This commit is contained in:
parent
4a73340150
commit
f12837fe32
7 changed files with 270 additions and 0 deletions
|
|
@ -20,6 +20,12 @@ pub enum HostRequest {
|
|||
Rebuild { name: String },
|
||||
/// List managed containers.
|
||||
List,
|
||||
/// List pending approval requests.
|
||||
Pending,
|
||||
/// Approve a pending request by id; the action runs immediately.
|
||||
Approve { id: i64 },
|
||||
/// Deny a pending request by id.
|
||||
Deny { id: i64 },
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
|
@ -29,6 +35,30 @@ pub struct HostResponse {
|
|||
pub error: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub agents: Option<Vec<String>>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub approvals: Option<Vec<Approval>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Approval {
|
||||
pub id: i64,
|
||||
pub agent: String,
|
||||
pub commit_ref: String,
|
||||
pub requested_at: i64,
|
||||
pub status: ApprovalStatus,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub resolved_at: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub note: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ApprovalStatus {
|
||||
Pending,
|
||||
Approved,
|
||||
Denied,
|
||||
Failed,
|
||||
}
|
||||
|
||||
impl HostResponse {
|
||||
|
|
@ -37,6 +67,7 @@ impl HostResponse {
|
|||
ok: true,
|
||||
error: None,
|
||||
agents: None,
|
||||
approvals: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -45,6 +76,7 @@ impl HostResponse {
|
|||
ok: false,
|
||||
error: Some(message.into()),
|
||||
agents: None,
|
||||
approvals: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -53,6 +85,16 @@ impl HostResponse {
|
|||
ok: true,
|
||||
error: None,
|
||||
agents: Some(agents),
|
||||
approvals: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pending(approvals: Vec<Approval>) -> Self {
|
||||
Self {
|
||||
ok: true,
|
||||
error: None,
|
||||
agents: None,
|
||||
approvals: Some(approvals),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -121,6 +163,13 @@ pub enum ManagerRequest {
|
|||
Kill {
|
||||
name: String,
|
||||
},
|
||||
/// Submit a config commit for the user to approve. `commit_ref` is opaque
|
||||
/// to the host (typically a git sha pointing into the agent's config repo).
|
||||
/// On approval the host applies the change via `nixos-container update`.
|
||||
RequestApplyCommit {
|
||||
agent: String,
|
||||
commit_ref: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue