Skip to content
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

Bugfix from manual test of new plugin generator on master #5355

Closed
wants to merge 5 commits into from
Closed
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
13 changes: 7 additions & 6 deletions lib/pluginmanager/generate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require "erb"
require "ostruct"
require "fileutils"
require "pathname"

class LogStash::PluginManager::Generate < LogStash::PluginManager::Command

Expand All @@ -14,17 +15,17 @@ class LogStash::PluginManager::Generate < LogStash::PluginManager::Command
arg
end

option "--name", "PLUGIN", "Name of the new plugin"
option "--name", "PLUGIN", "Name of the new plugin", :required => true
option "--path", "PATH", "Location where the plugin skeleton will be created", :default => Dir.pwd

def execute
source = File.join(File.dirname(__FILE__), "templates", "#{type}-plugin")
target_path = File.join(path, full_plugin_name)
FileUtils.mkdir(target_path)
puts " Creating #{target_path}"
@target_path = File.join(path, full_plugin_name)
FileUtils.mkdir(@target_path)
puts " Creating #{@target_path}"

begin
create_scaffold(source, target_path)
create_scaffold(source, @target_path)
rescue Errno::EACCES => exception
report_exception("Permission denied when executing the plugin manager", exception)
rescue => exception
Expand Down Expand Up @@ -55,7 +56,7 @@ def transform_r(source, target)
else
FileUtils.cp(source_entry, target_entry)
end
puts "\t create #{File.join(full_plugin_name, File.basename(target_entry))}"
puts "\t create #{File.join(full_plugin_name, Pathname.new(target_entry).relative_path_from(Pathname.new(@target_path)))}"
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class LogStash::Filters::<%= classify(plugin_name) %> < LogStash::Filters::Base
if @message
# Replace the event message with our message as configured in the
# config file.
event["message"] = @message
event.set("message", @message)
end

# filter_matched should go in the last line of our successful code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Gem::Specification.new do |s|
s.licenses = ['Apache License (2.0)']
s.summary = 'TODO: Write a short summary, because Rubygems requires one.'
s.description = 'TODO: Write a longer description or delete this line.'
s.homepage = 'TODO: Put your plugin's website or public repo URL here.'
s.homepage = 'TODO: Put your plugin''s website or public repo URL here.'
s.authors = ['<%= author %>']
s.email = '<%= email %>'
s.require_paths = ['lib']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe LogStash::Filters::<%= classify(plugin_name) %> do

sample("message" => "some text") do
expect(subject).to include("message")
expect(subject['message']).to eq('Hello World')
expect(subject.get('message')).to eq('Hello World')
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require "socket" # for Socket.gethostname
# This plugin is intented only as an example.

class LogStash::Inputs::<%= classify(plugin_name) %> < LogStash::Inputs::Base
config_name "<%= @lugin_name %>"
config_name "<%= @plugin_name %>"

# If undefined, Logstash will complain, even if codec is unused.
default :codec, "plain"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Gem::Specification.new do |s|
s.licenses = ['Apache License (2.0)']
s.summary = 'TODO: Write a short summary, because Rubygems requires one.'
s.description = '{TODO: Write a longer description or delete this line.'
s.homepage = 'TODO: Put your plugin's website or public repo URL here.'
s.homepage = 'TODO: Put your plugin''s website or public repo URL here.'
s.authors = ['<%= author %>']
s.email = '<%= email %>'
s.require_paths = ['lib']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Gem::Specification.new do |s|
s.licenses = ['Apache License (2.0)']
s.summary = 'TODO: Write a short summary, because Rubygems requires one.'
s.description = 'TODO: Write a longer description or delete this line.'
s.homepage = 'TODO: Put your plugin's website or public repo URL here.'
s.homepage = 'TODO: Put your plugin''s website or public repo URL here.'
s.authors = ['<%= author %>']
s.email = '<%= email %>'
s.require_paths = ['lib']
Expand Down