mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
parent
1ccfd1cf0f
commit
057238eb0f
4 changed files with 21 additions and 12 deletions
|
@ -15,6 +15,12 @@ module LogStash
|
|||
@gemset = nil
|
||||
end
|
||||
|
||||
def self.open(file_path)
|
||||
gemfile = new(::File.new(file_path, "r+"))
|
||||
gemfile.load
|
||||
gemfile
|
||||
end
|
||||
|
||||
def load
|
||||
@gemset ||= DSL.parse(@io.read)
|
||||
self
|
||||
|
@ -51,6 +57,11 @@ module LogStash
|
|||
def remove(name)
|
||||
@gemset.remove_gem(name)
|
||||
end
|
||||
|
||||
def close
|
||||
save if @gemset
|
||||
@io.close
|
||||
end
|
||||
end
|
||||
|
||||
class Gemset
|
||||
|
|
|
@ -32,7 +32,7 @@ class LogStash::PluginManager::Install < Clamp::Command
|
|||
end
|
||||
raise(LogStash::PluginManager::Error, "File #{LogStash::Environment::GEMFILE_PATH} does not exist or is not writable, aborting") unless File.writable?(LogStash::Environment::GEMFILE_PATH)
|
||||
|
||||
gemfile = LogStash::Gemfile.new(File.new(LogStash::Environment::GEMFILE_PATH, "r+")).load
|
||||
gemfile = LogStash::Gemfile.open(LogStash::Environment::GEMFILE_PATH)
|
||||
# keep a copy of the gemset to revert on error
|
||||
original_gemset = gemfile.gemset.copy
|
||||
|
||||
|
@ -58,17 +58,8 @@ class LogStash::PluginManager::Install < Clamp::Command
|
|||
end if verify?
|
||||
|
||||
# at this point we know that we either have a valid gem name & version or a valid .gem file path
|
||||
|
||||
# if LogStash::PluginManager.plugin_file?(plugin)
|
||||
# raise(LogStash::PluginManager::Error) unless cache_gem_file(plugin)
|
||||
# spec = LogStash::PluginManager.plugin_file_spec(plugin)
|
||||
# gemfile.update(spec.name, spec.version.to_s)
|
||||
# else
|
||||
# plugins.each{|tuple| gemfile.update(*tuple)}
|
||||
# end
|
||||
end
|
||||
|
||||
|
||||
install_list = LogStash::PluginManager.merge_duplicates(install_list)
|
||||
install_list.each{|plugin, version| gemfile.update(plugin, version)}
|
||||
gemfile.save
|
||||
|
@ -94,6 +85,9 @@ class LogStash::PluginManager::Install < Clamp::Command
|
|||
end
|
||||
|
||||
puts("Installation successful")
|
||||
|
||||
ensure
|
||||
gemfile.close if gemfile
|
||||
end
|
||||
|
||||
# copy .gem file into bundler cache directory, log any error to $stderr
|
||||
|
|
|
@ -15,7 +15,7 @@ class LogStash::PluginManager::Uninstall < Clamp::Command
|
|||
def execute
|
||||
raise(LogStash::PluginManager::Error, "File #{LogStash::Environment::GEMFILE_PATH} does not exist or is not writable, aborting") unless File.writable?(LogStash::Environment::GEMFILE_PATH)
|
||||
|
||||
gemfile = LogStash::Gemfile.new(File.new(LogStash::Environment::GEMFILE_PATH, "r+")).load
|
||||
gemfile = LogStash::Gemfile.open(LogStash::Environment::GEMFILE_PATH)
|
||||
# keep a copy of the gemset to revert on error
|
||||
original_gemset = gemfile.gemset.copy
|
||||
|
||||
|
@ -45,5 +45,7 @@ class LogStash::PluginManager::Uninstall < Clamp::Command
|
|||
raise(LogStash::PluginManager::Error, "Uninstall aborted")
|
||||
end
|
||||
end
|
||||
ensure
|
||||
gemfile.close if gemfile
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,7 +12,7 @@ class LogStash::PluginManager::Update < Clamp::Command
|
|||
parameter "[PLUGIN] ...", "Plugin name(s) to upgrade to latest version"
|
||||
|
||||
def execute
|
||||
gemfile = LogStash::Gemfile.new(File.new(LogStash::Environment::GEMFILE_PATH, "r+")).load
|
||||
gemfile = LogStash::Gemfile.open(LogStash::Environment::GEMFILE_PATH)
|
||||
# keep a copy of the gemset to revert on error
|
||||
original_gemset = gemfile.gemset.copy
|
||||
|
||||
|
@ -60,6 +60,8 @@ class LogStash::PluginManager::Update < Clamp::Command
|
|||
end
|
||||
end
|
||||
puts("No plugin updated") if update_count.zero?
|
||||
ensure
|
||||
gemfile.close
|
||||
end
|
||||
|
||||
private
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue