Offer better messaging around user/group creation (#557)

* Offer better messaging around user/group creation

* fmt
This commit is contained in:
Ana Hobden 2023-07-06 08:24:35 -07:00 committed by GitHub
parent edb72882fd
commit e5390faf1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -72,12 +72,16 @@ impl Action for CreateUsersAndGroups {
ActionTag("create_users_and_group")
}
fn tracing_synopsis(&self) -> String {
format!(
"Create build users (UID {}-{}) and group (GID {})",
self.nix_build_user_id_base,
self.nix_build_user_id_base + self.nix_build_user_count,
self.nix_build_group_id
)
if self.create_users.is_empty() {
format!("Create build group (GID {})", self.nix_build_group_id)
} else {
format!(
"Create build users (UID {}-{}) and group (GID {})",
self.nix_build_user_id_base,
self.nix_build_user_id_base + self.nix_build_user_count,
self.nix_build_group_id
)
}
}
fn tracing_span(&self) -> Span {
@ -239,10 +243,17 @@ impl Action for CreateUsersAndGroups {
explanation.append(&mut create_users_descriptions);
explanation.append(&mut add_user_to_group_descriptions);
vec![ActionDescription::new(
format!("Remove Nix users and group"),
explanation,
)]
if create_users.is_empty() {
vec![ActionDescription::new(
format!("Remove Nix group"),
explanation,
)]
} else {
vec![ActionDescription::new(
format!("Remove Nix users and group"),
explanation,
)]
}
}
#[tracing::instrument(level = "debug", skip_all)]