proxmox-tape: change lookup_drive_name to extract_drive_name

in most uses, we want to remove the drive from the param afterwards
where we don't, we already overwrite it with the result of this function

this fixes some commands (like 'proxmox-tape read-label --drive foo')
that failed with:

parameter 'drive': duplicate parameter.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak
2021-02-11 14:11:17 +01:00
committed by Dietmar Maurer
parent 96bcfb9b1f
commit 85cdc4f371
3 changed files with 48 additions and 42 deletions

View File

@ -42,7 +42,9 @@ pub fn lookup_changer_name(
return Ok(String::from(name));
}
if let Ok(drive) = crate::lookup_drive_name(&Value::Null, config) {
let mut empty = Value::Null;
if let Ok(drive) = crate::extract_drive_name(&mut empty, config) {
if let Ok(Some((_, name))) = media_changer(config, &drive) {
return Ok(name);
}

View File

@ -214,7 +214,7 @@ async fn restore_key(
) -> Result<(), Error> {
let (config, _digest) = config::drive::config()?;
param["drive"] = crate::lookup_drive_name(&param, &config)?.into();
param["drive"] = crate::extract_drive_name(&mut param, &config)?.into();
if !tty::stdin_isatty() {
bail!("no password input mechanism available");