Skip to content

Commit

Permalink
Backport fixes proposed in the plugin generator for the 2.x branch (#…
Browse files Browse the repository at this point in the history
…5362)

* fix to allow direct execution of 'bundle install'

Fixes #5355

* make plugin name parameter required

Fixes #5355

* display correct path of created files

Fixes #5355

* use new event api in generator filter template

Fixes #5355

* fix config_name for generated input plugin

Fixes #5355

* Revert "use new event api in generator filter template"

This reverts commit 0887685.
  • Loading branch information
purbon authored and Suyog Rao committed May 27, 2016
1 parent 5f00df9 commit a4aba9a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
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 @@ -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 @@ -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

0 comments on commit a4aba9a

Please sign in to comment.