Quellcode durchsuchen

Merge pull request #1722 from tgross35/case-insensitive-labels

Make label matching case insensitive
Mark Rousskov vor 1 Jahr
Ursprung
Commit
dbfa7359fc
1 geänderte Dateien mit 9 neuen und 1 gelöschten Zeilen
  1. 9 1
      src/handlers/relabel.rs

+ 9 - 1
src/handlers/relabel.rs

@@ -160,8 +160,12 @@ fn match_pattern(pattern: &str, label: &str) -> anyhow::Result<MatchPatternResul
     } else {
         (pattern, false)
     };
+
     let glob = glob::Pattern::new(pattern)?;
-    Ok(match (glob.matches(label), inverse) {
+    let mut matchopts = glob::MatchOptions::default();
+    matchopts.case_sensitive = false;
+
+    Ok(match (glob.matches_with(label, matchopts), inverse) {
         (true, false) => MatchPatternResult::Allow,
         (true, true) => MatchPatternResult::Deny,
         (false, _) => MatchPatternResult::NoMatch,
@@ -181,6 +185,10 @@ mod tests {
             match_pattern("I-*", "I-nominated")?,
             MatchPatternResult::Allow
         );
+        assert_eq!(
+            match_pattern("i-*", "I-nominated")?,
+            MatchPatternResult::Allow
+        );
         assert_eq!(
             match_pattern("!I-no*", "I-nominated")?,
             MatchPatternResult::Deny