Skip to content

Commit

Permalink
Changed config verify to return aggregated warnings (#1835)
Browse files Browse the repository at this point in the history
* Changed config verify to return aggregated warnings list for user to print instead of warn in current progress - can fix issues with extension where we printed to stderr.

* ..

* ..
  • Loading branch information
aviramha committed Aug 22, 2023
1 parent 5615118 commit f4a349f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.d/+config-verify-aggregated.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changed config verify to return aggregated warnings list for user to print instead of warn in current progress - can fix issues with extension where we printed to stderr.
6 changes: 5 additions & 1 deletion mirrord/cli/src/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ impl MirrordExecution {
where
P: Progress + Send + Sync,
{
config.verify()?;
let warnings = config.verify()?;
for warning in warnings {
progress.warning(&warning);
}

let lib_path = extract_library(None, progress, true)?;
let mut env_vars = HashMap::new();
let (connect_info, mut connection) = create_and_connect(config, progress).await?;
Expand Down
8 changes: 5 additions & 3 deletions mirrord/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,14 +321,16 @@ impl LayerConfig {

/// Verify that there are no conflicting settings.
/// We don't call it from `from_env` since we want to verify it only once (from cli)
pub fn verify(&self) -> Result<(), ConfigError> {
/// Returns vec of warnings
pub fn verify(&self) -> Result<Vec<String>, ConfigError> {
let mut warnings = Vec::new();
if self.pause {
if self.agent.ephemeral {
Err(ConfigError::Conflict("Pausing is not yet supported together with an ephemeral agent container.
Mutually exclusive arguments `--pause` and `--ephemeral-container` passed together.".to_string()))?;
}
if !self.feature.network.incoming.is_steal() {
warn!("{PAUSE_WITHOUT_STEAL_WARNING}");
warnings.push(PAUSE_WITHOUT_STEAL_WARNING.to_string());
}
}
if self
Expand Down Expand Up @@ -392,7 +394,7 @@ impl LayerConfig {
))?;
}
}
Ok(())
Ok(warnings)
}
}

Expand Down

0 comments on commit f4a349f

Please sign in to comment.