From 1c9034282c7dd1f67a19770397e7cd8f4a7a02be Mon Sep 17 00:00:00 2001 From: Andrey Kuzmin Date: Fri, 16 Mar 2018 11:19:57 +0100 Subject: [PATCH] Allow empty matchers --- ui/app/src/Utils/Filter.elm | 2 +- ui/app/src/Views/SilenceForm/Types.elm | 2 +- ui/app/tests/Filter.elm | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ui/app/src/Utils/Filter.elm b/ui/app/src/Utils/Filter.elm index 64486049..ac2f04c1 100644 --- a/ui/app/src/Utils/Filter.elm +++ b/ui/app/src/Utils/Filter.elm @@ -212,7 +212,7 @@ stringContents separator = |= keepOne (\char -> True) , Parser.keep Parser.oneOrMore (\char -> char /= separator && char /= '\\') ] - |> Parser.repeat Parser.oneOrMore + |> Parser.repeat Parser.zeroOrMore |> Parser.map (String.join "") diff --git a/ui/app/src/Views/SilenceForm/Types.elm b/ui/app/src/Views/SilenceForm/Types.elm index 3ded5476..da09c318 100644 --- a/ui/app/src/Views/SilenceForm/Types.elm +++ b/ui/app/src/Views/SilenceForm/Types.elm @@ -155,7 +155,7 @@ parseEndsAt startsAt endsAt = validateMatcherForm : MatcherForm -> MatcherForm validateMatcherForm { name, value, isRegex } = { name = validate stringNotEmpty name - , value = validate stringNotEmpty value + , value = value , isRegex = isRegex } diff --git a/ui/app/tests/Filter.elm b/ui/app/tests/Filter.elm index 1eaccc7e..bcaa3f34 100644 --- a/ui/app/tests/Filter.elm +++ b/ui/app/tests/Filter.elm @@ -13,6 +13,9 @@ parseMatcher = [ test "should parse empty matcher string" <| \() -> Expect.equal Nothing (Utils.Filter.parseMatcher "") + , test "should parse empty matcher value" <| + \() -> + Expect.equal (Just (Matcher "alertname" Eq "")) (Utils.Filter.parseMatcher "alertname=\"\"") , fuzz (tuple ( string, string )) "should parse random matcher string" <| \( key, value ) -> if List.map isNotEmptyTrimmedAlphabetWord [ key, value ] /= [ True, True ] then