src/config/remote.rs: add fingerprint

This commit is contained in:
Dietmar Maurer 2020-01-25 09:48:39 +01:00
parent dcb8db66d9
commit 6afbe1d846
3 changed files with 20 additions and 1 deletions

View File

@ -50,6 +50,10 @@ pub fn list_remotes(
password: { password: {
schema: remote::REMOTE_PASSWORD_SCHEMA, schema: remote::REMOTE_PASSWORD_SCHEMA,
}, },
fingerprint: {
optional: true,
schema: CERT_FINGERPRINT_SHA256_SCHEMA,
},
}, },
}, },
)] )]
@ -118,6 +122,10 @@ pub fn read_remote(name: String) -> Result<Value, Error> {
optional: true, optional: true,
schema: remote::REMOTE_PASSWORD_SCHEMA, schema: remote::REMOTE_PASSWORD_SCHEMA,
}, },
fingerprint: {
optional: true,
schema: CERT_FINGERPRINT_SHA256_SCHEMA,
},
digest: { digest: {
optional: true, optional: true,
schema: PROXMOX_CONFIG_DIGEST_SCHEMA, schema: PROXMOX_CONFIG_DIGEST_SCHEMA,
@ -132,6 +140,7 @@ pub fn update_remote(
host: Option<String>, host: Option<String>,
userid: Option<String>, userid: Option<String>,
password: Option<String>, password: Option<String>,
fingerprint: Option<String>,
digest: Option<String>, digest: Option<String>,
) -> Result<(), Error> { ) -> Result<(), Error> {
@ -158,6 +167,9 @@ pub fn update_remote(
if let Some(userid) = userid { data.userid = userid; } if let Some(userid) = userid { data.userid = userid; }
if let Some(password) = password { data.password = password; } if let Some(password) = password { data.password = password; }
// fixme: howto delete a fingeprint?
if let Some(fingerprint) = fingerprint { data.fingerprint = Some(fingerprint); }
config.set_data(&name, "remote", &data)?; config.set_data(&name, "remote", &data)?;
remote::save_config(&config)?; remote::save_config(&config)?;

View File

@ -476,7 +476,9 @@ pub fn complete_remote_datastore_name(_arg: &str, param: &HashMap<String, String
let client = HttpClient::new( let client = HttpClient::new(
&remote.host, &remote.host,
&remote.userid, &remote.userid,
Some(remote.password) Some(remote.password),
remote.fingerprint,
false,
)?; )?;
let mut rt = tokio::runtime::Runtime::new().unwrap(); let mut rt = tokio::runtime::Runtime::new().unwrap();

View File

@ -35,6 +35,10 @@ pub const REMOTE_PASSWORD_SCHEMA: Schema = StringSchema::new("Password or auth t
password: { password: {
schema: REMOTE_PASSWORD_SCHEMA, schema: REMOTE_PASSWORD_SCHEMA,
}, },
fingerprint: {
optional: true,
schema: CERT_FINGERPRINT_SHA256_SCHEMA,
},
} }
)] )]
#[derive(Serialize,Deserialize)] #[derive(Serialize,Deserialize)]
@ -45,6 +49,7 @@ pub struct Remote {
pub host: String, pub host: String,
pub userid: String, pub userid: String,
pub password: String, pub password: String,
pub fingerprint: Option<String>,
} }
fn init() -> SectionConfig { fn init() -> SectionConfig {