fix: Fixed a bug where --agent-variable values were not being passed to the agents
This commit is contained in:
@@ -204,6 +204,7 @@ impl Agent {
|
|||||||
|
|
||||||
pub fn init_agent_variables(
|
pub fn init_agent_variables(
|
||||||
agent_variables: &[AgentVariable],
|
agent_variables: &[AgentVariable],
|
||||||
|
pre_set_variables: Option<&AgentVariables>,
|
||||||
no_interaction: bool,
|
no_interaction: bool,
|
||||||
) -> Result<AgentVariables> {
|
) -> Result<AgentVariables> {
|
||||||
let mut output = IndexMap::new();
|
let mut output = IndexMap::new();
|
||||||
@@ -214,6 +215,10 @@ impl Agent {
|
|||||||
let mut unset_variables = vec![];
|
let mut unset_variables = vec![];
|
||||||
for agent_variable in agent_variables {
|
for agent_variable in agent_variables {
|
||||||
let key = agent_variable.name.clone();
|
let key = agent_variable.name.clone();
|
||||||
|
if let Some(value) = pre_set_variables.and_then(|v| v.get(&key)) {
|
||||||
|
output.insert(key, value.clone());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if let Some(value) = agent_variable.default.clone() {
|
if let Some(value) = agent_variable.default.clone() {
|
||||||
output.insert(key, value);
|
output.insert(key, value);
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
+10
-4
@@ -2607,8 +2607,11 @@ impl Config {
|
|||||||
None => return Ok(()),
|
None => return Ok(()),
|
||||||
};
|
};
|
||||||
if !agent.defined_variables().is_empty() && agent.shared_variables().is_empty() {
|
if !agent.defined_variables().is_empty() && agent.shared_variables().is_empty() {
|
||||||
let new_variables =
|
let new_variables = Agent::init_agent_variables(
|
||||||
Agent::init_agent_variables(agent.defined_variables(), self.info_flag)?;
|
agent.defined_variables(),
|
||||||
|
self.agent_variables.as_ref(),
|
||||||
|
self.info_flag,
|
||||||
|
)?;
|
||||||
agent.set_shared_variables(new_variables);
|
agent.set_shared_variables(new_variables);
|
||||||
}
|
}
|
||||||
if !self.info_flag {
|
if !self.info_flag {
|
||||||
@@ -2626,8 +2629,11 @@ impl Config {
|
|||||||
let shared_variables = agent.shared_variables().clone();
|
let shared_variables = agent.shared_variables().clone();
|
||||||
let session_variables =
|
let session_variables =
|
||||||
if !agent.defined_variables().is_empty() && shared_variables.is_empty() {
|
if !agent.defined_variables().is_empty() && shared_variables.is_empty() {
|
||||||
let new_variables =
|
let new_variables = Agent::init_agent_variables(
|
||||||
Agent::init_agent_variables(agent.defined_variables(), self.info_flag)?;
|
agent.defined_variables(),
|
||||||
|
self.agent_variables.as_ref(),
|
||||||
|
self.info_flag,
|
||||||
|
)?;
|
||||||
agent.set_shared_variables(new_variables.clone());
|
agent.set_shared_variables(new_variables.clone());
|
||||||
new_variables
|
new_variables
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user