mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2025-04-19 18:56:25 +02:00
Move to custom structure for actor_connection mapping - test
This commit is contained in:
parent
d5fe7cbe5c
commit
95241a6fd0
@ -243,8 +243,13 @@ pub fn load(
|
|||||||
.compat(),
|
.compat(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut actor_map: HashMap<String, _> = config
|
let mut actor_connections_data_vec: Vec<(String, String)> = vec![];
|
||||||
.actor_connections
|
for actor_connection in config.actor_connections.clone().into_iter() {
|
||||||
|
actor_connections_data_vec.push((actor_connection.machine, actor_connection.actor));
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut actor_map: HashMap<String, _> =
|
||||||
|
actor_connections_data_vec
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(k, v)| {
|
.filter_map(|(k, v)| {
|
||||||
if let Some(resource) = resources.get_by_id(v) {
|
if let Some(resource) = resources.get_by_id(v) {
|
||||||
|
@ -90,11 +90,12 @@ pub struct Config {
|
|||||||
|
|
||||||
/// Actors to load and their configuration options
|
/// Actors to load and their configuration options
|
||||||
pub actors: HashMap<String, ModuleConfig>,
|
pub actors: HashMap<String, ModuleConfig>,
|
||||||
pub actor_connections: HashMap<String, String>,
|
pub actor_connections: Vec<ActorConnectionConfig>,
|
||||||
|
|
||||||
/// Initiators to load and their configuration options
|
/// Initiators to load and their configuration options
|
||||||
pub initiators: HashMap<String, ModuleConfig>,
|
pub initiators: HashMap<String, ModuleConfig>,
|
||||||
pub init_connections: HashMap<String, String>,
|
pub init_connections: Vec<(String, String)>,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
@ -109,6 +110,18 @@ pub struct ModuleConfig {
|
|||||||
pub params: HashMap<String, String>,
|
pub params: HashMap<String, String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct ParamsConfig {
|
||||||
|
pub module: String,
|
||||||
|
pub params: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct ActorConnectionConfig {
|
||||||
|
pub machine: String,
|
||||||
|
pub actor: String,
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn deser_option<'de, D, T>(d: D) -> std::result::Result<Option<T>, D::Error>
|
pub(crate) fn deser_option<'de, D, T>(d: D) -> std::result::Result<Option<T>, D::Error>
|
||||||
where
|
where
|
||||||
D: serde::Deserializer<'de>,
|
D: serde::Deserializer<'de>,
|
||||||
@ -124,6 +137,16 @@ impl Default for Config {
|
|||||||
let mut roles: HashMap<String, Role> = HashMap::new();
|
let mut roles: HashMap<String, Role> = HashMap::new();
|
||||||
let mut machines: HashMap<String, MachineDescription> = HashMap::new();
|
let mut machines: HashMap<String, MachineDescription> = HashMap::new();
|
||||||
|
|
||||||
|
let mut initiator_123_params: HashMap<String, String> = HashMap::new();
|
||||||
|
initiator_123_params.insert("args".to_string(), "".to_string() );
|
||||||
|
initiator_123_params.insert("cmd".to_string(), "echo".to_string() );
|
||||||
|
|
||||||
|
let mut actor_connections_vec: Vec<ActorConnectionConfig> = vec![
|
||||||
|
ActorConnectionConfig {machine: "resource_a".to_string(), actor: "actor_123".to_string()},
|
||||||
|
ActorConnectionConfig {machine: "resource_b".to_string(), actor: "actor_123".to_string()}
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
roles.insert(
|
roles.insert(
|
||||||
"admin".to_string(),
|
"admin".to_string(),
|
||||||
Role {
|
Role {
|
||||||
@ -223,7 +246,7 @@ impl Default for Config {
|
|||||||
"initiator_123".to_string(),
|
"initiator_123".to_string(),
|
||||||
ModuleConfig {
|
ModuleConfig {
|
||||||
module: "Process".to_string(),
|
module: "Process".to_string(),
|
||||||
params: HashMap::new(),
|
params: initiator_123_params,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -248,9 +271,9 @@ impl Default for Config {
|
|||||||
roles,
|
roles,
|
||||||
machines,
|
machines,
|
||||||
actors,
|
actors,
|
||||||
actor_connections: vec!(("actor".to_string(), "actor_123".to_string()), ("machine".to_string(),"resource_a".to_string())).into_iter().collect(),
|
actor_connections: actor_connections_vec,
|
||||||
initiators,
|
initiators,
|
||||||
init_connections: vec!(("initiator".to_string(), "initiator_123".to_string()), ("machine".to_string(),"resource_b".to_string())).into_iter().collect(),
|
init_connections: vec![("initiator_123".to_string(), "resource_b".to_string())],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user