Skip to content

Commit

Permalink
Make label matching case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Sep 19, 2023
1 parent 9ea655c commit 7e45166
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/handlers/relabel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 7e45166

Please sign in to comment.