forked from elastic/logstash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate uninstall for Plugin Manager
Adds remove and deprecates uninstall Fixes elastic#6041 Fixes elastic#6042
- Loading branch information
Showing
7 changed files
with
90 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
qa/acceptance/spec/shared_examples/cli/logstash-plugin/remove.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# encoding: utf-8 | ||
require_relative "../../../spec_helper" | ||
require "logstash/version" | ||
require "fileutils" | ||
|
||
shared_examples "logstash uninstall" do |logstash| | ||
describe "logstash uninstall on #{logstash.hostname}" do | ||
before :each do | ||
logstash.install({:version => LOGSTASH_VERSION}) | ||
end | ||
|
||
after :each do | ||
logstash.uninstall | ||
end | ||
|
||
context "when the plugin isn't installed" do | ||
it "fails to remove it" do | ||
result = logstash.run_command_in_path("bin/logstash-plugin remove logstash-filter-qatest") | ||
expect(result.stderr).to match(/ERROR: Remove Aborted, message: This plugin has not been previously installed, aborting/) | ||
end | ||
end | ||
|
||
# Disabled because of this bug https://github.com/elastic/logstash/issues/5286 | ||
xcontext "when the plugin is installed" do | ||
it "succesfully removes it" do | ||
result = logstash.run_command_in_path("bin/logstash-plugin install logstash-filter-qatest") | ||
expect(logstash).to have_installed?("logstash-filter-qatest") | ||
|
||
result = logstash.run_command_in_path("bin/logstash-plugin remove logstash-filter-qatest") | ||
expect(result.stdout).to match(/^Removing logstash-filter-qatest/) | ||
expect(logstash).not_to have_installed?("logstash-filter-qatest") | ||
end | ||
end | ||
end | ||
end |