Skip to content

Commit

Permalink
fix: allowed tag parser parse everything
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasyl Portey committed Nov 3, 2020
1 parent 3bbe898 commit fce1a6b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cmd/builder/parser/tag/tag_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,15 @@ func parseValue(sc *scanner.Scanner) (interface{}, error) {
sc.Next()
return parseString(sc)
case '*':
sc.Next()
return "*", nil
r := sc.Next()
return string(r), nil
case '<', '>':
r := sc.Next()
if sc.Peek() == '=' {
sc.Next()
return string(r) + "=", nil
}
return string(r), nil
case '!':
sc.Next()
if sc.Peek() == '=' {
Expand Down
21 changes: 21 additions & 0 deletions cmd/builder/parser/tag/tag_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,27 @@ func TestParseTags(t *testing.T) {
},
})
})

t.Run("all_attributes", func(t *testing.T) {
tags, err := Parse("// Test:\"r=*,resource=['a','b','c'],any_key,upper,lower,con=<=,con2=>\"", []string{"Test"})
require.NoError(t, err)
assertEqualTags(t, tags, []Tag{
{
Name: "Test",
Attributes: map[string]interface{}{
"r": "*",
"resource": []interface{}{
"a", "b", "c",
},
"any_key": nil,
"upper": nil,
"lower": nil,
"con": "<=",
"con2": ">",
},
},
})
})
}

func assertEqualTags(t *testing.T, actual, expected []Tag) {
Expand Down

0 comments on commit fce1a6b

Please sign in to comment.