mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
add a validation fase with a warning in case you're updating plugins to a new major version
Fixes #3423
This commit is contained in:
parent
eb1d9baefd
commit
4677f0a54b
2 changed files with 19 additions and 4 deletions
|
@ -42,12 +42,13 @@ class LogStash::PluginManager::Update < LogStash::PluginManager::Command
|
|||
filtered_plugins = plugins.map { |plugin| gemfile.find(plugin) }
|
||||
.compact
|
||||
.reject { |plugin| REJECTED_OPTIONS.any? { |key| plugin.options.has_key?(key) } }
|
||||
.each { |plugin| gemfile.update(plugin.name) }
|
||||
.select { |plugin| validate_major_version(plugin.name) }
|
||||
.each { |plugin| gemfile.update(plugin.name) }
|
||||
|
||||
# force a disk sync before running bundler
|
||||
gemfile.save
|
||||
|
||||
puts("Updating #{filtered_plugins.collect(&:name).join(", ")}")
|
||||
puts("Updating #{filtered_plugins.collect(&:name).join(", ")}") unless filtered_plugins.empty?
|
||||
|
||||
# any errors will be logged to $stderr by invoke!
|
||||
# Bundler cannot update and clean gems in one operation so we have to call the CLI twice.
|
||||
|
@ -62,6 +63,20 @@ class LogStash::PluginManager::Update < LogStash::PluginManager::Command
|
|||
display_bundler_output(output)
|
||||
end
|
||||
|
||||
# validate if there is any major version update so then we can ask the user if he is
|
||||
# sure to update or not.
|
||||
def validate_major_version(plugin)
|
||||
require "gems"
|
||||
latest_version = Gems.versions(plugin)[0]['number'].split(".")
|
||||
current_version = Gem::Specification.find_by_name(plugin).version.version.split(".")
|
||||
if (latest_version[0].to_i > current_version[0].to_i)
|
||||
## warn if users want to continue
|
||||
puts("You are updating #{plugin} to a new version #{latest_version.join('.')}, which may not be compatible with #{current_version.join('.')}. are you sure you want to proceed (Y/N)?")
|
||||
return ( "y" == STDIN.gets.strip.downcase ? true : false)
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
# create list of plugins to update
|
||||
def plugins_to_update(previous_gem_specs_map)
|
||||
if update_all?
|
||||
|
|
|
@ -18,10 +18,11 @@ Gem::Specification.new do |gem|
|
|||
gem.version = LOGSTASH_VERSION
|
||||
|
||||
gem.add_runtime_dependency "cabin", "~> 0.7.0" #(Apache 2.0 license)
|
||||
gem.add_runtime_dependency "pry", "~> 0.10.1" #(Ruby license)
|
||||
gem.add_runtime_dependency "pry", "~> 0.10.1" #(Ruby license)
|
||||
gem.add_runtime_dependency "stud", "~> 0.0.19" #(Apache 2.0 license)
|
||||
gem.add_runtime_dependency "clamp", "~> 0.6.5" #(MIT license) for command line args/flags
|
||||
gem.add_runtime_dependency "filesize", "0.0.4" #(MIT license) for :bytes config validator
|
||||
gem.add_runtime_dependency "gems", "~> 0.8.3" #(MIT license)
|
||||
|
||||
# TODO(sissel): Treetop 1.5.x doesn't seem to work well, but I haven't
|
||||
# investigated what the cause might be. -Jordan
|
||||
|
@ -32,7 +33,6 @@ Gem::Specification.new do |gem|
|
|||
|
||||
# filetools and rakelib
|
||||
gem.add_runtime_dependency "minitar", "~> 0.5.4"
|
||||
|
||||
gem.add_runtime_dependency "thread_safe", "~> 0.3.5" #(Apache 2.0 license)
|
||||
|
||||
if RUBY_PLATFORM == 'java'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue