update config_util.rs
This commit is contained in:
@@ -8,7 +8,6 @@ use rust_util::{
|
||||
util_msg::*,
|
||||
};
|
||||
use chrono::{
|
||||
prelude::*,
|
||||
Utc,
|
||||
};
|
||||
|
||||
@@ -38,6 +37,7 @@ pub const DOT_OSS_BACKUPD_CONFIG: &str = ".oss-backupd-config.json";
|
||||
}
|
||||
*/
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct OSSConfig {
|
||||
pub endpoint: Option<String>,
|
||||
pub access_key_id: Option<String>,
|
||||
@@ -46,6 +46,7 @@ pub struct OSSConfig {
|
||||
pub path: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct OSSBackupdConfigItem {
|
||||
pub target: Option<String>,
|
||||
pub file_name: Option<String>,
|
||||
@@ -53,6 +54,7 @@ pub struct OSSBackupdConfigItem {
|
||||
pub encrypt_pubkey_file: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct OSSBackupdConfig {
|
||||
pub oss_config: Option<OSSConfig>,
|
||||
pub prefix: Option<String>,
|
||||
@@ -127,28 +129,33 @@ pub fn parse_oss_backupd_config_item(item: &json::JsonValue, root_oss_config_obj
|
||||
let file_name = get_string_value(item, "file_name");
|
||||
let mut encrypt_pubkey_file = get_string_value(item, "encrypt_pubkey_file");
|
||||
let mut oss_config = parse_sub_oss_config(item);
|
||||
if oss_config.is_some() && root_oss_config_object.is_some() {
|
||||
let mut oc = oss_config.unwrap();
|
||||
let root_oc = root_oss_config_object.as_ref().unwrap();
|
||||
if root_oss_config_object.is_some() {
|
||||
if oss_config.is_some() {
|
||||
let mut oc = oss_config.unwrap();
|
||||
let root_oc = root_oss_config_object.as_ref().unwrap();
|
||||
|
||||
if oc.endpoint.is_none() && root_oc.endpoint.is_some() {
|
||||
oc.endpoint = root_oc.endpoint.clone()
|
||||
if oc.endpoint.is_none() && root_oc.endpoint.is_some() {
|
||||
oc.endpoint = root_oc.endpoint.clone()
|
||||
}
|
||||
if oc.access_key_id.is_none() && root_oc.access_key_id.is_some() {
|
||||
oc.access_key_id = root_oc.access_key_id.clone()
|
||||
}
|
||||
if oc.access_key_secret.is_none() && root_oc.access_key_secret.is_some() {
|
||||
oc.access_key_secret = root_oc.access_key_secret.clone();
|
||||
}
|
||||
if oc.bucket.is_none() && root_oc.bucket.is_some() {
|
||||
oc.bucket = root_oc.bucket.clone();
|
||||
}
|
||||
if oc.path.is_none() && root_oc.path.is_some() {
|
||||
oc.path = root_oc.path.clone();
|
||||
}
|
||||
oss_config = Some(oc);
|
||||
} else {
|
||||
oss_config = root_oss_config_object.clone();
|
||||
}
|
||||
if oc.access_key_id.is_none() && root_oc.access_key_id.is_some() {
|
||||
oc.access_key_id = root_oc.access_key_id.clone()
|
||||
}
|
||||
if oc.access_key_secret.is_none() && root_oc.access_key_secret.is_some() {
|
||||
oc.access_key_secret = root_oc.access_key_secret.clone();
|
||||
}
|
||||
if oc.bucket.is_none() && root_oc.bucket.is_some() {
|
||||
oc.bucket = root_oc.bucket.clone();
|
||||
}
|
||||
if oc.path.is_none() && root_oc.path.is_some() {
|
||||
oc.path = root_oc.path.clone();
|
||||
}
|
||||
oss_config = Some(oc);
|
||||
}
|
||||
|
||||
|
||||
if encrypt_pubkey_file.is_none() && root_encrypt_pubkey_file.is_some() {
|
||||
encrypt_pubkey_file = root_encrypt_pubkey_file.clone();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user