From e5390faf1a6010a10f1c17814fc7038e3520205c Mon Sep 17 00:00:00 2001 From: Ana Hobden Date: Thu, 6 Jul 2023 08:24:35 -0700 Subject: [PATCH] Offer better messaging around user/group creation (#557) * Offer better messaging around user/group creation * fmt --- src/action/common/create_users_and_groups.rs | 31 +++++++++++++------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/action/common/create_users_and_groups.rs b/src/action/common/create_users_and_groups.rs index e460734..e388aaf 100644 --- a/src/action/common/create_users_and_groups.rs +++ b/src/action/common/create_users_and_groups.rs @@ -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)]