Skip to content

Commit

Permalink
Merge pull request #1722 from tgross35/case-insensitive-labels
Browse files Browse the repository at this point in the history
Make label matching case insensitive
  • Loading branch information
Mark-Simulacrum authored Sep 23, 2023
2 parents 08826fa + 7e45166 commit dbfa735
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 dbfa735

Please sign in to comment.