Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip global config file if SENTRY_SKIP_GLOBAL_CONFIG exists #1609

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DmitryCape
Copy link

Ignore global config if SENTRY_SKIP_GLOBAL_CONFIG exists

Issue: #1607

@kamilogorek
Copy link
Contributor

You can simplify this to:

diff --git src/config.rs src/config.rs
index 47d0f10..31b2616 100644
--- src/config.rs
+++ src/config.rs
@@ -500,20 +500,14 @@ fn load_global_config_file() -> Result<(PathBuf, Ini)> {
 }
 
 fn load_cli_config() -> Result<(PathBuf, Ini)> {
-    let mut rv = Ini::new();
-    let path: PathBuf;
-
-    match env::var("SENTRY_SKIP_GLOBAL_CONFIG") {
-        Ok(_) => {
-            path = find_project_config_file()
-                .ok_or_else(|| Error::msg("Failed to find project config file"))?;
-        }
-        Err(_) => {
-            let (global_filename, global_rv) = load_global_config_file()?;
-            path = global_filename;
-            rv = global_rv;
-        }
-    }
+    let (mut path, mut rv) = if env::var("SENTRY_SKIP_GLOBAL_CONFIG")
+        .map(|x| x.as_str() == "1")
+        .unwrap_or(false)
+    {
+        (PathBuf::new(), Ini::new())
+    } else {
+        load_global_config_file()?
+    };
 
     if let Some(project_config_path) = find_project_config_file() {
         let file_desc = format!(
@@ -529,6 +523,7 @@ fn load_cli_config() -> Result<(PathBuf, Ini)> {
                 rv.set_to(section, key.to_string(), value.to_owned());
             }
         }
+        path = project_config_path;
     }
 
     if let Ok(prop_path) = env::var("SENTRY_PROPERTIES") {

However, this change will break the behavior of sentry-cli login, as it's not possible to create a file from an empty PathBuf. We should most likely use cwd instead and log the warn/info about the skipping part + new default path used.

@github-actions
Copy link

github-actions bot commented Jun 7, 2023

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants