Skip to content

plugin-api 2.0 #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
sudo: false
jdk:
- oraclejdk8
language: ruby
cache: bundler
rvm:
- jruby-1.7.23
script:
- jruby-1.7.25
before_install:
- git clone -b feature/event_interface https://github.com/elastic/logstash
script:
- bundle exec rspec spec
9 changes: 8 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
source 'https://rubygems.org'
gemspec
gemspec

# this is temporary for the feature/plugin-api-2_0 branch and is meant for travis testing
gem "logstash-core", :path => "./logstash/logstash-core"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious, won't this hinder plugin authors? Like if they 'git clone' this repo and want to run the test suite, it's probably not going to find logstash-core in ./logstash/logstash-core

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this is temporary for this refactor branch and will be removed once we are ready to merge back in master. this is just to allow Travis to build on that branch without having to publish ai core gems. see https://github.com/logstash-plugins/logstash-filter-grok/blob/feature/plugin-api-2_0/.travis.yml#L9

gem "logstash-core-plugin-api", :path => "./logstash/logstash-core-plugin-api"
gem "logstash-core-event-java", :path => "./logstash/logstash-core-event-java"
gem "logstash-devutils", :github => "elastic/logstash-devutils", :branch => "feature/plugin-api-2_0"
gem "logstash-patterns-core", :github => "logstash-plugins/logstash-patterns-core", :branch => "feature/plugin-api-2_0"
16 changes: 7 additions & 9 deletions lib/logstash/filters/grok.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def register
# will let folks redefine built-in patterns at runtime.
@patternfiles += patterns_files_from_paths(@@patterns_path.to_a, "*")
@patternfiles += patterns_files_from_paths(@patterns_dir, @patterns_files_glob)

@patterns = Hash.new { |h,k| h[k] = [] }

@logger.info? and @logger.info("Match data", :match => @match)
Expand All @@ -269,8 +269,6 @@ def register

public
def filter(event)


matched = false
done = false

Expand All @@ -294,7 +292,7 @@ def filter(event)

private
def match(groks, field, event)
input = event[field]
input = event.get(field)
if input.is_a?(Array)
success = false
input.each do |input|
Expand Down Expand Up @@ -327,21 +325,21 @@ def handle(field, value, event)
return if (value.nil? || (value.is_a?(String) && value.empty?)) unless @keep_empty_captures

if @overwrite.include?(field)
event[field] = value
event.set(field, value)
else
v = event[field]
v = event.get(field)
if v.nil?
event[field] = value
event.set(field, value)
elsif v.is_a?(Array)
# do not replace the code below with:
# event[field] << value
# this assumes implementation specific feature of returning a mutable object
# from a field ref which should not be assumed and will change in the future.
v << value
event[field] = v
event.set(field, v)
elsif v.is_a?(String)
# Promote to array since we aren't overwriting.
event[field] = [v, value]
event.set(field, [v, value])
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion logstash-filter-grok.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Gem::Specification.new do |s|
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }

# Gem dependencies
s.add_runtime_dependency "logstash-core-plugin-api", "~> 1.0"
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"

s.add_runtime_dependency 'jls-grok', '~> 0.11.1'
s.add_runtime_dependency 'logstash-patterns-core'
Expand Down
Loading