Skip to content

Commit dbfa735

Browse files
Merge pull request #1722 from tgross35/case-insensitive-labels
Make label matching case insensitive
2 parents 08826fa + 7e45166 commit dbfa735

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/handlers/relabel.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,12 @@ fn match_pattern(pattern: &str, label: &str) -> anyhow::Result<MatchPatternResul
160160
} else {
161161
(pattern, false)
162162
};
163+
163164
let glob = glob::Pattern::new(pattern)?;
164-
Ok(match (glob.matches(label), inverse) {
165+
let mut matchopts = glob::MatchOptions::default();
166+
matchopts.case_sensitive = false;
167+
168+
Ok(match (glob.matches_with(label, matchopts), inverse) {
165169
(true, false) => MatchPatternResult::Allow,
166170
(true, true) => MatchPatternResult::Deny,
167171
(false, _) => MatchPatternResult::NoMatch,
@@ -181,6 +185,10 @@ mod tests {
181185
match_pattern("I-*", "I-nominated")?,
182186
MatchPatternResult::Allow
183187
);
188+
assert_eq!(
189+
match_pattern("i-*", "I-nominated")?,
190+
MatchPatternResult::Allow
191+
);
184192
assert_eq!(
185193
match_pattern("!I-no*", "I-nominated")?,
186194
MatchPatternResult::Deny

0 commit comments

Comments
 (0)