mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
Proposed implementation for installation warnings
This commit is contained in:
parent
d85bdbc4e1
commit
72204bd0fc
2 changed files with 10 additions and 9 deletions
|
@ -232,10 +232,10 @@ module InspecPlugins
|
|||
|
||||
# Already installed?
|
||||
if registry.known_plugin?(plugin_name.to_sym)
|
||||
ui.red("Plugin already installed - #{plugin_name} - Use '#{EXEC_NAME} " \
|
||||
"plugin list' to see previously installed plugin - " \
|
||||
"installation failed.\n")
|
||||
ui.exit Inspec::UI::EXIT_PLUGIN_ERROR
|
||||
ui.bold("Plugin already installed - #{plugin_name} - Use '#{EXEC_NAME} " \
|
||||
"plugin list' to see previously installed plugin - " \
|
||||
"installation failed.\n")
|
||||
ui.exit Inspec::UI::EXIT_NORMAL
|
||||
end
|
||||
|
||||
# Can we figure out how to load it?
|
||||
|
@ -391,8 +391,9 @@ module InspecPlugins
|
|||
they_explicitly_asked_for_a_version = !options[:version].nil?
|
||||
what_we_would_install_is_already_installed = pre_installed_versions.include?(requested_version)
|
||||
if what_we_would_install_is_already_installed && they_explicitly_asked_for_a_version
|
||||
ui.red("Plugin already installed at requested version - plugin " \
|
||||
ui.bold("Plugin already installed at requested version - plugin " \
|
||||
"#{plugin_name} #{requested_version} - refusing to install.\n")
|
||||
ui.exit Inspec::UI::EXIT_NORMAL
|
||||
elsif what_we_would_install_is_already_installed && !they_explicitly_asked_for_a_version
|
||||
ui.red("Plugin already installed at latest version - plugin " \
|
||||
"#{plugin_name} #{requested_version} - refusing to install.\n")
|
||||
|
@ -462,10 +463,10 @@ module InspecPlugins
|
|||
latest_version = latest_version[plugin_name]&.last
|
||||
|
||||
if pre_update_versions.include?(latest_version)
|
||||
ui.plain_line("#{ui.red("Already installed at latest version:", print: false)} " \
|
||||
ui.plain_line("#{ui.bold("Already installed at latest version:", print: false)} " \
|
||||
"#{plugin_name} is at #{latest_version}, which the " \
|
||||
"latest - refusing to update")
|
||||
ui.exit Inspec::UI::EXIT_PLUGIN_ERROR
|
||||
ui.exit Inspec::UI::EXIT_NORMAL
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ class PluginManagerCliInstall < Minitest::Test
|
|||
|
||||
assert_empty install_result.stderr
|
||||
|
||||
assert_exit_code 2, install_result
|
||||
assert_exit_code 0, install_result
|
||||
end
|
||||
|
||||
def test_fail_install_from_path_when_the_dir_structure_is_wrong
|
||||
|
@ -268,7 +268,7 @@ class PluginManagerCliInstall < Minitest::Test
|
|||
|
||||
assert_empty install_result.stderr
|
||||
|
||||
assert_exit_code 2, install_result
|
||||
assert_exit_code 0, install_result
|
||||
end
|
||||
|
||||
def test_refuse_install_when_already_installed_can_update
|
||||
|
|
Loading…
Reference in a new issue