From 0f56416d82b032a6a4e0adf518c52789d69b0528 Mon Sep 17 00:00:00 2001 From: Steffen Eiden Date: Tue, 7 Apr 2026 13:58:38 +0200 Subject: [PATCH] pvsecret: Improve UX on non-s390 systems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If pvsecret {add, list, retrieve} is executed with options on a non-s390 system the user gets misleading error messages as the options are not defined. > pvsecret add -i secret.bin error: unexpected argument '-i' found This may lead the user to think wrong arguments where chosen, which is not entirely true as they are valid on s390. The more helpful error message would be error: Command only available on s390x Which is already the case if no arguments are given. Solve this by allowing non-s390 systems to parse the options: > pvsecret add -i secret.bin error: Command only available on s390x Reported-by: Carlo Della Giusta Fixes: dd82c26f879d ("rust: Add tool to manage UV-secrets") Reviewed-by: Jan Höppner Signed-off-by: Steffen Eiden Signed-off-by: Jan Höppner --- rust/pvsecret/src/cli.rs | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/rust/pvsecret/src/cli.rs b/rust/pvsecret/src/cli.rs index 5ce445df..9ddda198 100644 --- a/rust/pvsecret/src/cli.rs +++ b/rust/pvsecret/src/cli.rs @@ -265,12 +265,10 @@ impl Display for RetrieveableSecretInpKind { } } -// all members s390x only #[derive(Args, Debug)] pub struct AddSecretOpt { /// Specify the request to be sent. #[arg(value_name = "FILE", value_hint = ValueHint::FilePath,)] - #[cfg(target_arch = "s390x")] pub input: String, /// Force the addition of add-secret requests. @@ -282,7 +280,6 @@ pub struct AddSecretOpt { } #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Debug, Default)] -#[cfg(target_arch = "s390x")] pub enum ListSecretOutputType { /// Human-focused, non-parsable output format #[default] @@ -293,17 +290,14 @@ pub enum ListSecretOutputType { Bin, } -// all members s390x only #[derive(Args, Debug)] pub struct ListSecretOpt { /// Store the result in FILE #[arg(value_name = "FILE", default_value = STDOUT, value_hint = ValueHint::FilePath,)] - #[cfg(target_arch = "s390x")] pub output: String, /// Define the output format of the list. #[arg(long, value_enum, default_value_t)] - #[cfg(target_arch = "s390x")] pub format: ListSecretOutputType, } @@ -331,7 +325,6 @@ pub struct VerifyOpt { pub output: String, } -// all members s390x only #[derive(Args, Debug)] pub struct RetrSecretOptions { /// Specify the secret ID to be retrieved. @@ -341,22 +334,18 @@ pub struct RetrSecretOptions { /// handle encodes in hexadecimal. Leading zeros are required. If there are multiple secrets in /// the store with the same Id there are no guarantees on which specific secret is retrieved. /// Use --inform=idx to make sure a specific secret is retrieved. - #[cfg(target_arch = "s390x")] #[arg(value_name = "ID", value_hint = ValueHint::FilePath)] pub input: String, /// Specify the output path to place the secret value - #[cfg(target_arch = "s390x")] #[arg(short, long, value_name = "FILE", default_value = STDOUT, value_hint = ValueHint::FilePath)] pub output: String, /// Define input type for the Secret ID - #[cfg(target_arch = "s390x")] #[arg(long, value_enum, default_value_t)] pub inform: RetrInpFmt, /// Define the output format for the retrieved secret - #[cfg(target_arch = "s390x")] #[arg(long, value_enum, default_value_t)] pub outform: RetrOutFmt, } @@ -478,10 +467,7 @@ mod test { vec!["pvsecret", "lock"], vec!["pvsecret", "version"], vec!["pvsecret", "list"], - #[cfg(target_arch = "s390x")] vec!["pvsecret", "add", "abc"], - #[cfg(not(target_arch = "s390x"))] - vec!["pvsecret", "add"], vec!["pvsecret", "create", "-k", "abc", "--hdr", "abc", "-o", "abc", "--no-verify", "meta"], vec!["pvsecret", "create", "-k", "abc", "--hdr", "abc", "-o", "abc", "--no-verify", "association", "name" ], vec!["pvsecret", "create", "-k", "abc", "--hdr", "abc", "-o", "abc", "--no-verify", "update-cck", "--secret", "abc"], @@ -492,11 +478,8 @@ mod test { "--root-ca", "tttt", "--cck", "cck", "--cuid-hex", "0x11223344556677889900aabbccddeeff", "--pcf", "0x123", "association", "name", "--stdout", "--output-secret", "secret"], vec!["pvsecret", "create", "-k", "abc", "--hdr", "abc", "-o", "abc", "--no-verify", "association", "name", "--output-secret", "secret"], - #[cfg(target_arch = "s390x")] vec!["pvsecret", "list", "--format", "human"], - #[cfg(target_arch = "s390x")] vec!["pvsecret", "list", "--format", "yaml"], - #[cfg(target_arch = "s390x")] vec!["pvsecret", "list", "--format", "bin"], ]; // Test for the minimal amount of flags to yield an invalid combination