public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: Thomas Lamprecht <t.lamprecht@proxmox.com>, pbs-devel@lists.proxmox.com
Subject: Re: [PATCH v4 5/5] fix #5340: client: repository: add PBS_NAMESPACE environment variable
Date: Fri, 17 Apr 2026 14:23:13 +0200	[thread overview]
Message-ID: <e7f23300-3a44-47cb-9bc9-097a1c743d7b@proxmox.com> (raw)
In-Reply-To: <20260410154327.4133440-6-t.lamprecht@proxmox.com>

2 nits inline, might however be folder in when appying

On 4/10/26 5:43 PM, Thomas Lamprecht wrote:
> Add PBS_NAMESPACE as a fallback when --ns is not given on the CLI,
> addressing the request in bug #5340.
> 
> The env var is supported uniformly across all client tools
> (proxmox-backup-client, proxmox-file-restore, proxmox-backup-debug).
> Like the other PBS_* atom env vars, it provides a default that can be
> overridden by the corresponding CLI option.
> 
> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
> ---
> 
> changes v3 -> v4:
> - env var fallback now lives in the shared optional_ns_param() in
>    pbs-client tools (moved in patch 3), so this patch only upgrades that
>    single function instead of touching all three binaries
> - made ENV_VAR_PBS_NAMESPACE private (consistent with other
>    ENV_VAR_PBS_* constants, no external users after the move)
> 
>   docs/backup-client.rst      |  3 +++
>   pbs-client/src/tools/mod.rs | 16 +++++++++++-----
>   2 files changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/docs/backup-client.rst b/docs/backup-client.rst
> index 1d464a007..e2a05d4fc 100644
> --- a/docs/backup-client.rst
> +++ b/docs/backup-client.rst
> @@ -131,6 +131,9 @@ Environment Variables
>     Authentication identity (``user@realm`` or ``user@realm!tokenname``).
>     Defaults to ``root@pam`` if unset.
>   
> +``PBS_NAMESPACE``
> +  Backup namespace. Used as a fallback when ``--ns`` is not given.
> +
>   ``PBS_PASSWORD``
>     When set, this value is used as the password for the backup server.
>     You can also set this to an API token secret.
> diff --git a/pbs-client/src/tools/mod.rs b/pbs-client/src/tools/mod.rs
> index fa708a8b5..e034b9a31 100644
> --- a/pbs-client/src/tools/mod.rs
> +++ b/pbs-client/src/tools/mod.rs
> @@ -36,6 +36,7 @@ const ENV_VAR_PBS_SERVER: &str = "PBS_SERVER";
>   const ENV_VAR_PBS_PORT: &str = "PBS_PORT";
>   const ENV_VAR_PBS_DATASTORE: &str = "PBS_DATASTORE";
>   const ENV_VAR_PBS_AUTH_ID: &str = "PBS_AUTH_ID";
> +const ENV_VAR_PBS_NAMESPACE: &str = "PBS_NAMESPACE";
>   
>   /// Directory with system [credential]s. See systemd-creds(1).
>   ///
> @@ -339,13 +340,17 @@ pub fn extract_repository_from_map(param: &HashMap<String, String>) -> Option<Ba
>       resolve_repository(cli).ok()
>   }
>   
> -/// Extract a [`BackupNamespace`] from CLI parameters.
> +/// Extract a [`BackupNamespace`] from CLI parameters, falling back to PBS_NAMESPACE.
>   pub fn optional_ns_param(param: &Value) -> Result<BackupNamespace, Error> {
> -    Ok(match param.get("ns") {
> -        Some(Value::String(ns)) => ns.parse()?,
> +    match param.get("ns") {
> +        Some(Value::String(ns)) => return ns.parse().map_err(Error::from),

nit: introduces a clippy useless_conversion warning, the error type here 
already is anyhow::Error

>           Some(_) => bail!("invalid namespace parameter"),
> -        None => BackupNamespace::root(),
> -    })
> +        None => {}
> +    }
> +    if let Ok(ns) = std::env::var(ENV_VAR_PBS_NAMESPACE) {
> +        return ns.parse().map_err(Error::from);


nit: same as above

> +    }
> +    Ok(BackupNamespace::root())
>   }
>   
>   pub fn connect(repo: &BackupRepository) -> Result<HttpClient, Error> {
> @@ -849,6 +854,7 @@ mod tests {
>           ENV_VAR_PBS_PORT,
>           ENV_VAR_PBS_DATASTORE,
>           ENV_VAR_PBS_AUTH_ID,
> +        ENV_VAR_PBS_NAMESPACE,
>           ENV_VAR_CREDENTIALS_DIRECTORY,
>       ];
>   





  reply	other threads:[~2026-04-17 12:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-10 14:09 [PATCH v4 0/5] client: repository: add individual component parameters Thomas Lamprecht
2026-04-10 14:09 ` [PATCH v4 1/5] client: repository: add tests for BackupRepository parsing Thomas Lamprecht
2026-04-10 14:09 ` [PATCH v4 2/5] client: repository: add individual component parameters Thomas Lamprecht
2026-04-10 14:09 ` [PATCH v4 3/5] client: migrate commands to flattened repository args Thomas Lamprecht
2026-04-10 14:09 ` [PATCH v4 4/5] docs: document repository component options and env vars Thomas Lamprecht
2026-04-10 14:09 ` [PATCH v4 5/5] fix #5340: client: repository: add PBS_NAMESPACE environment variable Thomas Lamprecht
2026-04-17 12:23   ` Christian Ebner [this message]
2026-04-17 12:26 ` [PATCH v4 0/5] client: repository: add individual component parameters Christian Ebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e7f23300-3a44-47cb-9bc9-097a1c743d7b@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    --cc=t.lamprecht@proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal