Merged
Conversation
- make requests concurrent - rename modules - simplify core api
Comment on lines
+28
to
+42
| fn replace_env_placeholders(config: &mut String) { | ||
| let result = RE_ENV.replace_all(config, |caps: &Captures| { | ||
| // caps[0] is "${VAR}" | ||
| // caps[1] is "VAR" | ||
| let var_name = &caps[1]; | ||
| // TODO is there a better way to handle this? It would be better to bubble this up since it is not recoverable | ||
| match env::var(var_name) { | ||
| Ok(val) => val, | ||
| Err(_) => panic!("Could not find env.var = {}", &caps[0]), | ||
| } | ||
| }); | ||
|
|
||
| if let Cow::Owned(new_content) = result { | ||
| *config = new_content; | ||
| } |
There was a problem hiding this comment.
Consider returning a Result error instead of panicking when an environment variable is missing so that the error can be handled gracefully. This would allow the caller to manage the failure without an abrupt termination.
Suggested change
| fn replace_env_placeholders(config: &mut String) { | |
| let result = RE_ENV.replace_all(config, |caps: &Captures| { | |
| // caps[0] is "${VAR}" | |
| // caps[1] is "VAR" | |
| let var_name = &caps[1]; | |
| // TODO is there a better way to handle this? It would be better to bubble this up since it is not recoverable | |
| match env::var(var_name) { | |
| Ok(val) => val, | |
| Err(_) => panic!("Could not find env.var = {}", &caps[0]), | |
| } | |
| }); | |
| if let Cow::Owned(new_content) = result { | |
| *config = new_content; | |
| } | |
| fn replace_env_placeholders(config: &mut String) -> Result<()> { | |
| let result = RE_ENV.replace_all(config, |caps: &Captures| { | |
| // caps[0] is "${VAR}" | |
| // caps[1] is "VAR" | |
| let var_name = &caps[1]; | |
| match env::var(var_name) { | |
| Ok(val) => val, | |
| Err(_) => return Err(anyhow::anyhow!("Missing environment variable: {}", &caps[0])), | |
| } | |
| }); | |
| if let Cow::Owned(new_content) = result { | |
| *config = new_content; | |
| } | |
| Ok(()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request includes extensive changes to the
venoproject, focusing on renaming modules, refactoring code, and improving the configuration and notification system. The most important changes include renaming thecliandcoremodules, refactoring theAppConfigandArtifactstructures, and enhancing the notification system.Module Renaming:
clitoveno-cliandcoretoveno-coreinCargo.tomland updated paths accordingly. [1] [2] [3]Refactoring:
AppConfigandArtifactstructures and their associated methods fromcore/src/config.rsandcore/src/artifact/mod.rs. [1] [2]AppStatestructure inveno-core/src/app.rsto handle application state and configuration loading.AppConfigto a simpler structure inveno-core/src/config.rs.Artifactstructure and methods inveno-core/src/artifact/mod.rs.Notification System Enhancements:
artifact_idsto theNotifierstructure to link notifiers to specific artifacts.sendmethod inSinkimplementations to use a consistentnotificationparameter. [1] [2]AppStateto handle artifact version checks and notifications.Dependency Management:
anyhowandtokioas workspace dependencies inCargo.toml.veno-cli/Cargo.tomlandveno-core/Cargo.tomlto use workspace versions. [1] [2]Miscellaneous:
core/src/lib.rstoveno-core/src/lib.rsand updated module imports. [1] [2]EmailSinkandSlackSinkimplementations. [1] [2]These changes collectively improve the structure, maintainability, and functionality of the
venoproject.