Skip to content
Snippets Groups Projects
Verified Commit 12f48f08 authored by David Runge's avatar David Runge :chipmunk:
Browse files

feat: Add `UserMapping::has_system_and_nethsm_user`


Add a function to easily evaluate whether a `UserMapping` has a system
user and at least one NetHSM user.

Signed-off-by: default avatarDavid Runge <dvzrv@archlinux.org>
parent 57aa0448
No related branches found
No related tags found
1 merge request!179Add various extensions and improvements for nethsm-config
#[cfg(doc)]
use nethsm::NetHsm;
use nethsm::{KeyId, SigningKeySetup, UserId};
use serde::{Deserialize, Serialize};
......@@ -616,4 +618,47 @@ impl UserMapping {
} => vec![],
}
}
/// Returns whether the mapping has both system and [`NetHsm`] users.
///
/// Returns `true` if the `self` has at least one system and one [`NetHsm`] user, and `false`
/// otherwise.
pub fn has_system_and_nethsm_user(&self) -> bool {
match self {
UserMapping::SystemNetHsmOperatorSigning {
nethsm_user: _,
nethsm_key_setup: _,
system_user: _,
ssh_authorized_key: _,
tag: _,
}
| UserMapping::HermeticSystemNetHsmMetrics {
nethsm_users: _,
system_user: _,
}
| UserMapping::SystemNetHsmMetrics {
nethsm_users: _,
system_user: _,
ssh_authorized_key: _,
}
| UserMapping::SystemNetHsmBackup {
nethsm_user: _,
system_user: _,
ssh_authorized_key: _,
} => true,
UserMapping::SystemOnlyShareDownload {
system_user: _,
ssh_authorized_keys: _,
}
| UserMapping::SystemOnlyShareUpload {
system_user: _,
ssh_authorized_keys: _,
}
| UserMapping::SystemOnlyWireGuardDownload {
system_user: _,
ssh_authorized_keys: _,
}
| UserMapping::NetHsmOnlyAdmin(_) => false,
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment