Feature: A way to install/remove a plugin pack

A pack in this context is a *bundle* of plugins that can be distributed outside of rubygems; it is similar to what ES and kibana are doing, and
the user interface is modeled after them. See https://www.elastic.co/downloads/x-pack

**Do not mix it with the `bin/logstash-plugin pack/unpack` command.**

- it contains one or more plugins that need to be installed
- it is self-contains with the gems and the needed jars
- it is distributed as a zip file
- the file structure needs to follow some rules.

- As a reserved name name on elastic.co download http server
    - `bin/plugin install logstash-mypack` will check on the download server if a pack for the current specific logstash version exist and it will be downloaded, if it doesn't exist we fallback on rubygems.
    - The file on the server will follow this convention `logstash-mypack-{LOGSTASH_VERSION}.zip`

- As a fully qualified url
    - `bin/plugin install http://test.abc/logstash-mypack.zip`, if it exists it will be downloaded and installed if it does not we raise an error.

- As a local file
    - `bin/plugin install file:///tmp/logstash-mypack.zip`, if it exists it will be installed

Fixes #6168
This commit is contained in:
Pier-Hugues Pellerin 2016-10-20 14:50:15 -04:00
parent 270c90f8c6
commit 12cfa69215
47 changed files with 1629 additions and 80 deletions

View file

@ -1,8 +1,8 @@
# encoding: utf-8
require "pluginmanager/bundler/logstash_uninstall"
require "pluginmanager/command"
class LogStash::PluginManager::Remove < LogStash::PluginManager::Command
parameter "PLUGIN", "plugin name"
def execute
@ -19,23 +19,10 @@ class LogStash::PluginManager::Remove < LogStash::PluginManager::Command
# it is not possible to uninstall a dependency not listed in the Gemfile, for example a dependent codec
signal_error("This plugin has not been previously installed, aborting") unless LogStash::PluginManager.installed_plugin?(plugin, gemfile)
# since we previously did a gemfile.find(plugin) there is no reason why
# remove would not work (return nil) here
if gemfile.remove(plugin)
gemfile.save
exit(1) unless ::Bundler::LogstashUninstall.uninstall!(plugin)
puts("Removing #{plugin}")
# any errors will be logged to $stderr by invoke!
# output, exception = LogStash::Bundler.invoke!(:install => true, :clean => true)
output = LogStash::Bundler.invoke!(:install => true, :clean => true)
remove_unused_locally_installed_gems!
end
remove_unused_locally_installed_gems!
rescue => exception
gemfile.restore!
report_exception("Remove Aborted", exception)
ensure
display_bundler_output(output)
report_exception("Operation aborted, cannot remove plugin.", exception)
end
end