Skip to content

Commit

Permalink
Take another approach
Browse files Browse the repository at this point in the history
Signed-off-by: gotjosh <josue.abreu@gmail.com>
  • Loading branch information
gotjosh committed Sep 30, 2022
1 parent 124d963 commit 6dd17d8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 2 additions & 6 deletions pkg/labels/parse.go
Expand Up @@ -120,18 +120,14 @@ func ParseMatcher(s string) (_ *Matcher, err error) {
return nil, errors.Errorf("bad matcher format: %s", s)
}

rawValue := ms[3]
if len(rawValue) == 0 {
return nil, errors.Errorf("matcher value is not present: %s", s)
}

var (
rawValue = ms[3]
value strings.Builder
escaped bool
expectTrailingQuote bool
)

if rawValue[0] == '"' {
if strings.HasPrefix(rawValue, "\"") {
rawValue = strings.TrimPrefix(rawValue, "\"")
expectTrailingQuote = true
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/labels/parse_test.go
Expand Up @@ -191,7 +191,10 @@ func TestMatchers(t *testing.T) {
},
{
input: `job=`,
err: `matcher value is not present: job=`,
want: func() []*Matcher {
m, _ := NewMatcher(MatchEqual, "job", "")
return []*Matcher{m}
}(),
},
{
input: `job="value`,
Expand Down

0 comments on commit 6dd17d8

Please sign in to comment.