mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
config grammar: Allow spaces in [field references][like this]
Tests included. Note about grammar compilation: I had to use treetop 1.4.15 (1.5.3 generates ruby code that fails to parse, haven't spent any time debugging) Fixes #1513
This commit is contained in:
parent
0f790649bc
commit
4c86e3342f
3 changed files with 24 additions and 4 deletions
|
@ -3453,7 +3453,7 @@ module LogStashConfig
|
|||
if r1
|
||||
s2, i2 = [], index
|
||||
loop do
|
||||
if has_terminal?('\G[^\\], ]', true, index)
|
||||
if has_terminal?('\G[^\\],]', true, index)
|
||||
r3 = true
|
||||
@index += 1
|
||||
else
|
||||
|
|
|
@ -234,7 +234,7 @@ grammar LogStashConfig
|
|||
end
|
||||
|
||||
rule selector_element
|
||||
"[" [^\], ]+ "]"
|
||||
"[" [^\],]+ "]"
|
||||
<LogStash::Config::AST::SelectorElement>
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
require "test_utils"
|
||||
|
||||
module ConditionalFancines
|
||||
module ConditionalFanciness
|
||||
def description
|
||||
return example.metadata[:example_group][:description_args][0]
|
||||
end
|
||||
|
@ -23,7 +23,7 @@ end
|
|||
|
||||
describe "conditionals" do
|
||||
extend LogStash::RSpec
|
||||
extend ConditionalFancines
|
||||
extend ConditionalFanciness
|
||||
|
||||
describe "simple" do
|
||||
config <<-CONFIG
|
||||
|
@ -320,4 +320,24 @@ describe "conditionals" do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "field references" do
|
||||
conditional "[field with space]" do
|
||||
sample("field with space" => "hurray") do
|
||||
insist { subject["tags"].include?("success") }
|
||||
end
|
||||
end
|
||||
|
||||
conditional "[field with space] == 'hurray'" do
|
||||
sample("field with space" => "hurray") do
|
||||
insist { subject["tags"].include?("success") }
|
||||
end
|
||||
end
|
||||
|
||||
conditional "[nested field][reference with][some spaces] == 'hurray'" do
|
||||
sample({"nested field" => { "reference with" => { "some spaces" => "hurray" } } }) do
|
||||
insist { subject["tags"].include?("success") }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue