mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
Deprecate uninstall for Plugin Manager
Adds remove and deprecates uninstall Fixes #6041 Fixes #6042
This commit is contained in:
parent
3b1a0fd4b0
commit
44a52ff18e
7 changed files with 90 additions and 6 deletions
41
lib/pluginmanager/remove.rb
Normal file
41
lib/pluginmanager/remove.rb
Normal file
|
@ -0,0 +1,41 @@
|
|||
# encoding: utf-8
|
||||
require "pluginmanager/command"
|
||||
|
||||
class LogStash::PluginManager::Remove < LogStash::PluginManager::Command
|
||||
|
||||
parameter "PLUGIN", "plugin name"
|
||||
|
||||
def execute
|
||||
signal_error("File #{LogStash::Environment::GEMFILE_PATH} does not exist or is not writable, aborting") unless File.writable?(LogStash::Environment::GEMFILE_PATH)
|
||||
|
||||
##
|
||||
# Need to setup the bundler status to enable uninstall of plugins
|
||||
# installed as local_gems, otherwise gem:specification is not
|
||||
# finding the plugins
|
||||
##
|
||||
LogStash::Bundler.setup!({:without => [:build, :development]})
|
||||
|
||||
# make sure this is an installed plugin and present in Gemfile.
|
||||
# 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
|
||||
|
||||
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
|
||||
rescue => exception
|
||||
gemfile.restore!
|
||||
report_exception("Remove Aborted", exception)
|
||||
ensure
|
||||
display_bundler_output(output)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue