Skip to content

Commit

Permalink
Rename bin/plugin to bin/logstash-plugin
Browse files Browse the repository at this point in the history
This adds support for packs and fixes the problem where bin/plugin
pollutes the PATH namespace

Fixes elastic#4871

Fixes elastic#4874
  • Loading branch information
suyograo committed Mar 24, 2016
1 parent 48bfff3 commit 683302e
Show file tree
Hide file tree
Showing 20 changed files with 54 additions and 54 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ You can install the default set of plugins included in the logstash package or a
rake test:install-all

---
Note that if a plugin is installed using the plugin manager `bin/plugin install ...` do not forget to also install the plugins development dependencies using the following command after the plugin installation:
Note that if a plugin is installed using the plugin manager `bin/logstash-plugin install ...` do not forget to also install the plugins development dependencies using the following command after the plugin installation:

bin/plugin install --development
bin/logstash-plugin install --development

## Developing plugins

Expand Down
2 changes: 1 addition & 1 deletion bin/plugin → bin/logstash-plugin
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ unset CDPATH
. "$(cd `dirname $0`/..; pwd)/bin/logstash.lib.sh"
setup

# bin/plugin is a short lived ruby script thus we can use aggressive "faster starting JRuby options"
# bin/logstash-plugin is a short lived ruby script thus we can use aggressive "faster starting JRuby options"
# see https://github.com/jruby/jruby/wiki/Improving-startup-time
export JRUBY_OPTS="$JRUBY_OPTS -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-noverify -X-C -Xcompile.invokedynamic=false"

Expand Down
2 changes: 1 addition & 1 deletion docs/plugin-doc.asciidoc.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
=== <%= name %>

<% unless default_plugin %>
NOTE: This is a community-maintained plugin! It does not ship with Logstash by default, but it is easy to install by running `bin/plugin install logstash-<%= section %>-<%= plugin_name %>`.
NOTE: This is a community-maintained plugin! It does not ship with Logstash by default, but it is easy to install by running `bin/logstash-plugin install logstash-<%= section %>-<%= plugin_name %>`.
<% end %>

<%= description %>
Expand Down
8 changes: 4 additions & 4 deletions docs/static/include/pluginbody.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -845,7 +845,7 @@ Gem::Specification.new do |s|
s.version = '0.1.0'
s.licenses = ['Apache License (2.0)']
s.summary = "This {plugintype} does x, y, z in Logstash"
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
s.authors = ["Elastic"]
s.email = '[email protected]'
s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
Expand Down Expand Up @@ -1051,7 +1051,7 @@ environment, and `0.1.0` with the correct version number from the gemspec file.
[source,sh]
[subs="attributes"]
----------------------------------
bin/plugin install /my/logstash/plugins/logstash-{plugintype}-{pluginname}/logstash-{plugintype}-{pluginname}-0.1.0.gem
bin/logstash-plugin install /my/logstash/plugins/logstash-{plugintype}-{pluginname}/logstash-{plugintype}-{pluginname}-0.1.0.gem
----------------------------------
+
* After running this, you should see feedback from Logstash that it was
Expand All @@ -1072,7 +1072,7 @@ currently available:
[source,sh]
----------------------------------
bin/plugin list
bin/logstash-plugin list
----------------------------------
Depending on what you have installed, you might see a short or long list of
plugins: inputs, codecs, filters and outputs.
Expand Down Expand Up @@ -1275,7 +1275,7 @@ by running:
[source,sh]
[subs="attributes"]
----------------------------------
bin/plugin install logstash-{plugintype}-mypluginname
bin/logstash-plugin install logstash-{plugintype}-mypluginname
----------------------------------

==== Contributing your source code to https://github.com/logstash-plugins[logstash-plugins]
Expand Down
2 changes: 1 addition & 1 deletion docs/static/monitoring-apis.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ consumption. The default for the `human` flag is
experimental[]

The plugins API gets information about all Logstash plugins that are currently installed.
This API basically returns the output of running the `bin/plugins list --verbose` command.
This API basically returns the output of running the `bin/logstash-plugin list --verbose` command.

[source,js]
--------------------------------------------------
Expand Down
16 changes: 8 additions & 8 deletions docs/static/offline-plugins.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ all available plugins. You can distribute this bundle to all nodes without furth
Working with offline plugins requires you to create an _offline package_, which is a compressed file that contains all of
the plugins your offline Logstash installation requires, along with the dependencies for those plugins.

. Create the offline package with the `bin/plugin pack` subcommand.
. Create the offline package with the `bin/logstash-plugin pack` subcommand.
+
When you run the `bin/plugin pack` subcommand, Logstash creates a compressed bundle that contains all of the currently
When you run the `bin/logstash-plugin pack` subcommand, Logstash creates a compressed bundle that contains all of the currently
installed plugins and the dependencies for those plugins. By default, the compressed bundle is a GZipped TAR file when you
run the `bin/plugin pack` subcommand on a UNIX machine. By default, when you run the `bin/plugin pack` subcommand on a
run the `bin/logstash-plugin pack` subcommand on a UNIX machine. By default, when you run the `bin/logstash-plugin pack` subcommand on a
Windows machine, the compressed bundle is a ZIP file. See <<managing-packs,Managing Plugin Packs>> for details on changing
these default behaviors.
+
NOTE: Downloading all dependencies for the specified plugins may take some time, depending on the plugins listed.

. Move the compressed bundle to the offline machines that are the source for offline plugin installation, then use the
`bin/plugin unpack` subcommand to make the packaged plugins available.
`bin/logstash-plugin unpack` subcommand to make the packaged plugins available.

[float]
=== Install or Update a local plugin
Expand All @@ -41,24 +41,24 @@ examples:

.Installing a local plugin
============
`bin/plugin install --local logstash-input-jdbc`
`bin/logstash-plugin install --local logstash-input-jdbc`
============

.Updating a local plugin
============
`bin/plugin update --local logstash-input-jdbc`
`bin/logstash-plugin update --local logstash-input-jdbc`
============

.Updating all local plugins in one command
============
`bin/plugin update --local`
`bin/logstash-plugin update --local`
============

[float]
[[managing-packs]]
=== Managing Plugin Packs

The `pack` and `unpack` subcommands for `bin/plugin` take the following options:
The `pack` and `unpack` subcommands for `bin/logstash-plugin` take the following options:

[horizontal]
`--tgz`:: Generate the offline package as a GZipped TAR file. The default behavior on UNIX systems.
Expand Down
22 changes: 11 additions & 11 deletions docs/static/plugin-manager.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
== Working with plugins

Logstash has a rich collection of input, filter, codec and output plugins. Plugins are available as self-contained
packages called gems and hosted on RubyGems.org. The plugin manager accesed via `bin/plugin` script is used to manage the
packages called gems and hosted on RubyGems.org. The plugin manager accesed via `bin/logstash-plugin` script is used to manage the
lifecycle of plugins in your Logstash deployment. You can install, uninstall and upgrade plugins using these Command Line
Interface (CLI) described below.

Expand All @@ -15,10 +15,10 @@ available in your deployment:

[source,shell]
----------------------------------
bin/plugin list <1>
bin/plugin list --verbose <2>
bin/plugin list *namefragment* <3>
bin/plugin list --group output <4>
bin/logstash-plugin list <1>
bin/logstash-plugin list --verbose <2>
bin/logstash-plugin list *namefragment* <3>
bin/logstash-plugin list --group output <4>
----------------------------------
<1> Will list all installed plugins

Expand All @@ -38,7 +38,7 @@ installation.

[source,shell]
----------------------------------
bin/plugin install logstash-output-kafka
bin/logstash-plugin install logstash-output-kafka
----------------------------------

Once the plugin is successfully installed, you can start using it in your configuration file.
Expand All @@ -52,7 +52,7 @@ provides you the option to install a locally built plugin which is packaged as a

[source,shell]
----------------------------------
bin/plugin install /path/to/logstash-output-kafka-1.0.0.gem
bin/logstash-plugin install /path/to/logstash-output-kafka-1.0.0.gem
----------------------------------

[[installing-local-plugins-path]]
Expand All @@ -76,8 +76,8 @@ subcommand you can get the latest or update to a particular version of the plugi

[source,shell]
----------------------------------
bin/plugin update <1>
bin/plugin update logstash-output-kafka <2>
bin/logstash-plugin update <1>
bin/logstash-plugin update logstash-output-kafka <2>
----------------------------------
<1> will update all installed plugins

Expand All @@ -91,7 +91,7 @@ If you need to remove plugins from your Logstash installation:

[source,shell]
----------------------------------
bin/plugin uninstall logstash-output-kafka
bin/logstash-plugin uninstall logstash-output-kafka
----------------------------------

[[proxy-plugins]]
Expand All @@ -106,7 +106,7 @@ Proxy is used to handle HTTP requests. Logstash Plugins can be installed and upd
----------------------------------
export HTTP_PROXY=http://127.0.0.1:3128
bin/plugin install logstash-output-kafka
bin/logstash-plugin install logstash-output-kafka
----------------------------------

Once set, plugin commands install, update can be used through this proxy.
Expand Down
2 changes: 1 addition & 1 deletion docs/static/upgrading.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ These plugin updates are available for Logstash 2.0. To upgrade to the latest ve
plugins, the command is:

[source,shell]
bin/plugin update <plugin_name>
bin/logstash-plugin update <plugin_name>

**Multiline Filter:** If you are using the Multiline Filter in your configuration and upgrade to Logstash 2.0,
you will get an error. Make sure to explicitly set the number of filter workers (`-w`) to `1`. You can set the number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
}

before :all do
command("bin/plugin install logstash-input-file logstash-output-file")
command("bin/logstash-plugin install logstash-input-file logstash-output-file")
end

it "writes events to file" do
Expand Down
10 changes: 5 additions & 5 deletions integration/plugin_manager/plugin_install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
require_relative "../spec_helper"
require "fileutils"

context "bin/plugin install" do
context "bin/logstash-plugin install" do
context "with a local gem" do
let(:gem_name) { "logstash-input-wmi" }
let(:local_gem) { gem_fetch(gem_name) }

it "install the gem succesfully" do
result = command("bin/plugin install --no-verify #{local_gem}")
result = command("bin/logstash-plugin install --no-verify #{local_gem}")
expect(result.exit_status).to eq(0)
expect(result.stdout).to match(/^Installing\s#{gem_name}\nInstallation\ssuccessful$/)
end
Expand All @@ -18,22 +18,22 @@
let(:plugin_name) { "logstash-input-drupal_dblog" }

it "sucessfully install" do
result = command("bin/plugin install #{plugin_name}")
result = command("bin/logstash-plugin install #{plugin_name}")
expect(result.exit_status).to eq(0)
expect(result.stdout).to match(/^Validating\s#{plugin_name}\nInstalling\s#{plugin_name}\nInstallation\ssuccessful$/)
end

it "allow to install a specific version" do
version = "2.0.2"
result = command("bin/plugin install --version 2.0.2 #{plugin_name}")
result = command("bin/logstash-plugin install --version 2.0.2 #{plugin_name}")
expect(result.exit_status).to eq(0)
expect(result.stdout).to match(/^Validating\s#{plugin_name}-#{version}\nInstalling\s#{plugin_name}\nInstallation\ssuccessful$/)
end
end

context "when the plugin doesn't exist" do
it "fails to install" do
result = command("bin/plugin install --no-verify logstash-output-impossible-plugin")
result = command("bin/logstash-plugin install --no-verify logstash-output-impossible-plugin")
expect(result.exit_status).to eq(1)
expect(result.stderr).to match(/Installation Aborted, message: Could not find gem/)
end
Expand Down
12 changes: 6 additions & 6 deletions integration/plugin_manager/plugin_list_spec.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Encoding: utf-8
require_relative "../spec_helper"

describe "bin/plugin list" do
describe "bin/logstash-plugin list" do
context "without a specific plugin" do
it "display a list of plugins" do
result = command("bin/plugin list")
result = command("bin/logstash-plugin list")
expect(result.exit_status).to eq(0)
expect(result.stdout.split("\n").size).to be > 1
end

it "display a list of installed plugins" do
result = command("bin/plugin list --installed")
result = command("bin/logstash-plugin list --installed")
expect(result.exit_status).to eq(0)
expect(result.stdout.split("\n").size).to be > 1
end

it "list the plugins with their versions" do
result = command("bin/plugin list --verbose")
result = command("bin/logstash-plugin list --verbose")
result.stdout.split("\n").each do |plugin|
expect(plugin).to match(/^logstash-\w+-\w+\s\(\d+\.\d+.\d+\)/)
end
Expand All @@ -27,13 +27,13 @@
context "with a specific plugin" do
let(:plugin_name) { "logstash-input-stdin" }
it "list the plugin and display the plugin name" do
result = command("bin/plugin list #{plugin_name}")
result = command("bin/logstash-plugin list #{plugin_name}")
expect(result.stdout).to match(/^#{plugin_name}$/)
expect(result.exit_status).to eq(0)
end

it "list the plugin with his version" do
result = command("bin/plugin list --verbose #{plugin_name}")
result = command("bin/logstash-plugin list --verbose #{plugin_name}")
expect(result.stdout).to match(/^#{plugin_name} \(\d+\.\d+.\d+\)/)
expect(result.exit_status).to eq(0)
end
Expand Down
8 changes: 4 additions & 4 deletions integration/plugin_manager/plugin_uninstall_spec.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Encoding: utf-8
require_relative "../spec_helper"

describe "bin/plugin uninstall" do
describe "bin/logstash-plugin uninstall" do
context "when the plugin isn't installed" do
it "fails to uninstall it" do
result = command("bin/plugin uninstall logstash-filter-cidr")
result = command("bin/logstash-plugin uninstall logstash-filter-cidr")
expect(result.stderr).to match(/ERROR: Uninstall Aborted, message: This plugin has not been previously installed, aborting/)
expect(result.exit_status).to eq(1)
end
Expand All @@ -13,9 +13,9 @@
context "when the plugin is installed" do
it "succesfully uninstall it" do
# make sure we have the plugin installed.
command("bin/plugin install logstash-filter-ruby")
command("bin/logstash-plugin install logstash-filter-ruby")

result = command("bin/plugin uninstall logstash-filter-ruby")
result = command("bin/logstash-plugin uninstall logstash-filter-ruby")

expect(result.stdout).to match(/^Uninstalling logstash-filter-ruby/)
expect(result.exit_status).to eq(0)
Expand Down
2 changes: 1 addition & 1 deletion lib/bootstrap/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def pattern_path(path)
end


# when launched as a script, not require'd, (currently from bin/logstash and bin/plugin) the first
# when launched as a script, not require'd, (currently from bin/logstash and bin/logstash-plugin) the first
# argument is the path of a Ruby file to require and a LogStash::Runner class is expected to be
# defined and exposing the LogStash::Runner#main instance method which will be called with the current ARGV
# currently lib/logstash/runner.rb and lib/pluginmanager/main.rb are called using this.
Expand Down
4 changes: 2 additions & 2 deletions lib/pluginmanager/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class LogStash::PluginManager::Install < LogStash::PluginManager::Command
option "--version", "VERSION", "version of the plugin to install"
option "--[no-]verify", :flag, "verify plugin validity before installation", :default => true
option "--development", :flag, "install all development dependencies of currently installed plugins", :default => false
option "--local", :flag, "force local-only plugin installation. see bin/plugin package|unpack", :default => false
option "--local", :flag, "force local-only plugin installation. see bin/logstash-plugin package|unpack", :default => false

# the install logic below support installing multiple plugins with each a version specification
# but the argument parsing does not support it for now so currently if specifying --version only
Expand Down Expand Up @@ -112,7 +112,7 @@ def install_gems_list!(install_list)

# Extract the specified local gems in a predefined local path
# Update the gemfile to use a relative path to this plugin and run
# Bundler, this will mark the gem not updatable by `bin/plugin update`
# Bundler, this will mark the gem not updatable by `bin/logstash-plugin update`
# This is the most reliable way to make it work in bundler without
# hacking with `how bundler works`
#
Expand Down
2 changes: 1 addition & 1 deletion lib/pluginmanager/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class LogStash::PluginManager::List < LogStash::PluginManager::Command

parameter "[PLUGIN]", "Part of plugin name to search for, leave empty for all plugins"

option "--installed", :flag, "List only explicitly installed plugins using bin/plugin install ...", :default => false
option "--installed", :flag, "List only explicitly installed plugins using bin/logstash-plugin install ...", :default => false
option "--verbose", :flag, "Also show plugin version number", :default => false
option "--group", "NAME", "Filter plugins per group: input, output, filter or codec" do |arg|
raise(ArgumentError, "should be one of: input, output, filter or codec") unless ['input', 'output', 'filter', 'codec'].include?(arg)
Expand Down
2 changes: 1 addition & 1 deletion lib/pluginmanager/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Main < Clamp::Command

if $0 == __FILE__
begin
LogStash::PluginManager::Main.run("bin/plugin", ARGV)
LogStash::PluginManager::Main.run("bin/logstash-plugin", ARGV)
rescue LogStash::PluginManager::Error => e
$stderr.puts(e.message)
exit(1)
Expand Down
2 changes: 1 addition & 1 deletion lib/pluginmanager/unpack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def execute
validate_cache_location
archive_manager.extract(package_file, LogStash::Environment::CACHE_PATH)
puts("Unpacked at #{LogStash::Environment::CACHE_PATH}")
puts("The unpacked plugins can now be installed in local-only mode using bin/plugin install --local [plugin name]")
puts("The unpacked plugins can now be installed in local-only mode using bin/logstash-plugin install --local [plugin name]")
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/pluginmanager/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class LogStash::PluginManager::Update < LogStash::PluginManager::Command

parameter "[PLUGIN] ...", "Plugin name(s) to upgrade to latest version", :attribute_name => :plugins_arg
option "--[no-]verify", :flag, "verify plugin validity before installation", :default => true
option "--local", :flag, "force local-only plugin update. see bin/plugin package|unpack", :default => false
option "--local", :flag, "force local-only plugin update. see bin/logstash-plugin package|unpack", :default => false

def execute
local_gems = gemfile.locally_installed_gems
Expand Down
2 changes: 1 addition & 1 deletion rakelib/package.rake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace "package" do

task "bundle" do
system("bin/plugin", "package")
system("bin/logstash-plugin", "package")
raise(RuntimeError, $!.to_s) unless $?.success?
end

Expand Down
Loading

0 comments on commit 683302e

Please sign in to comment.