worker_state: move tasktype() code to src/api2/node/tasks.rs

Because this is API related code, and only used there.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Dietmar Maurer
2021-09-21 07:58:54 +02:00
committed by Thomas Lamprecht
parent e678a50ea1
commit fd18775ac1
2 changed files with 11 additions and 11 deletions

View File

@ -116,6 +116,15 @@ fn check_task_access(auth_id: &Authid, upid: &UPID) -> Result<(), Error> {
}
}
pub fn tasktype(state: &TaskState) -> TaskStateType {
match state {
TaskState::OK { .. } => TaskStateType::OK,
TaskState::Unknown { .. } => TaskStateType::Unknown,
TaskState::Error { .. } => TaskStateType::Error,
TaskState::Warning { .. } => TaskStateType::Warning,
}
}
#[api(
input: {
properties: {
@ -492,7 +501,7 @@ pub fn list_tasks(
(Some(_), _) if running => continue,
(Some(crate::server::TaskState::OK { .. }), _) if errors => continue,
(Some(state), Some(filters)) => {
if !filters.contains(&state.tasktype()) {
if !filters.contains(&tasktype(state)) {
continue;
}
},