mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
Merge pull request #682 from bodgit/notin
Make 'if "something" not in [nonexistent] { ... }' succeed
This commit is contained in:
commit
e400039aa7
2 changed files with 3 additions and 1 deletions
|
@ -299,7 +299,7 @@ module LogStash; module Config; module AST
|
||||||
module NotInExpression
|
module NotInExpression
|
||||||
def compile
|
def compile
|
||||||
item, list = recursive_select(LogStash::Config::AST::RValue)
|
item, list = recursive_select(LogStash::Config::AST::RValue)
|
||||||
return "(x = #{list.compile}; x.respond_to?(:include?) && !x.include?(#{item.compile}))"
|
return "(x = #{list.compile}; !x.respond_to?(:include?) || !x.include?(#{item.compile}))"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -162,6 +162,7 @@ describe "conditionals" do
|
||||||
if !("foo" not in "foo") { mutate { add_tag => "notfoo" } }
|
if !("foo" not in "foo") { mutate { add_tag => "notfoo" } }
|
||||||
if "foo" not in [somelist] { mutate { add_tag => "notsomelist" } }
|
if "foo" not in [somelist] { mutate { add_tag => "notsomelist" } }
|
||||||
if "one" not in [somelist] { mutate { add_tag => "somelist" } }
|
if "one" not in [somelist] { mutate { add_tag => "somelist" } }
|
||||||
|
if "foo" not in [alsomissing] { mutate { add_tag => "no string in missing field" } }
|
||||||
}
|
}
|
||||||
CONFIG
|
CONFIG
|
||||||
|
|
||||||
|
@ -174,6 +175,7 @@ describe "conditionals" do
|
||||||
insist { subject["tags"] }.include?("notfoo")
|
insist { subject["tags"] }.include?("notfoo")
|
||||||
insist { subject["tags"] }.include?("notsomelist")
|
insist { subject["tags"] }.include?("notsomelist")
|
||||||
reject { subject["tags"] }.include?("somelist")
|
reject { subject["tags"] }.include?("somelist")
|
||||||
|
insist { subject["tags"] }.include?("no string in missing field")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue