derive/impl and use Default for some structs

and revamp HttpClientOptions with two constructors for the common use
cases

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler
2021-01-25 14:42:57 +01:00
committed by Wolfgang Bumiller
parent f4e52bb27d
commit 93e3581ce7
10 changed files with 50 additions and 40 deletions

View File

@ -211,13 +211,7 @@ fn connect_do(server: &str, port: u16, auth_id: &Authid) -> Result<HttpClient, E
Err(NotPresent) => None,
};
let options = HttpClientOptions::new()
.prefix(Some("proxmox-backup".to_string()))
.password(password)
.interactive(true)
.fingerprint(fingerprint)
.fingerprint_cache(true)
.ticket_cache(true);
let options = HttpClientOptions::new_interactive(password, fingerprint);
HttpClient::new(server, port, auth_id, options)
}
@ -1565,13 +1559,9 @@ async fn try_get(repo: &BackupRepository, url: &str) -> Value {
let fingerprint = std::env::var(ENV_VAR_PBS_FINGERPRINT).ok();
let password = std::env::var(ENV_VAR_PBS_PASSWORD).ok();
let options = HttpClientOptions::new()
.prefix(Some("proxmox-backup".to_string()))
.password(password)
.interactive(false)
.fingerprint(fingerprint)
.fingerprint_cache(true)
.ticket_cache(true);
// ticket cache, but no questions asked
let options = HttpClientOptions::new_interactive(password, fingerprint)
.interactive(false);
let client = match HttpClient::new(repo.host(), repo.port(), repo.auth_id(), options) {
Ok(v) => v,