core: better output for BoxCheckOutdated

This commit is contained in:
Mitchell Hashimoto 2014-01-24 15:41:26 -08:00
parent ea06202903
commit bfca65b098
3 changed files with 22 additions and 3 deletions

View File

@ -20,6 +20,11 @@ module Vagrant
if !machine.config.vm.box_check_update if !machine.config.vm.box_check_update
return @app.call(env) return @app.call(env)
end end
if !env.has_key?(:box_outdated_refresh)
env[:box_outdated_refresh] = true
env[:box_outdated_ignore_errors] = true
end
end end
if !machine.box if !machine.box
@ -30,9 +35,17 @@ module Vagrant
end end
if env[:box_outdated_refresh] if env[:box_outdated_refresh]
@logger.info( env[:ui].output(I18n.t(
"Checking if box is outdated by refreshing metadata") "vagrant.box_outdated_checking_with_refresh",
check_outdated_refresh(env) name: machine.box.name))
begin
check_outdated_refresh(env)
rescue Errors::VagrantError => e
raise if !env[:box_outdated_ignore_errors]
env[:ui].detail(I18n.t(
"vagrant.box_outdated_metadata_error",
message: e.message))
end
else else
@logger.info("Checking if box is outdated locally") @logger.info("Checking if box is outdated locally")
check_outdated_local(env) check_outdated_local(env)

View File

@ -307,6 +307,7 @@ module VagrantPlugins
end end
b.use ConfigValidate b.use ConfigValidate
b.use BoxCheckOutdated
b.use Call, Created do |env, b2| b.use Call, Created do |env, b2|
# If the VM is NOT created yet, then do the setup steps # If the VM is NOT created yet, then do the setup steps
if !env[:result] if !env[:result]

View File

@ -30,11 +30,16 @@ en:
Loading metadata for box '%{name}' Loading metadata for box '%{name}'
box_outdated: |- box_outdated: |-
* '%{name}' is outdated! Current: %{current}. Latest: %{latest} * '%{name}' is outdated! Current: %{current}. Latest: %{latest}
box_outdated_checking_with_refresh: |-
Checking if box '%{name}' is up to date...
box_outdated_local: |- box_outdated_local: |-
A newer version of the box '%{name}' is available and already A newer version of the box '%{name}' is available and already
installed, but your Vagrant machine is running against installed, but your Vagrant machine is running against
version '%{old}'. To update to version '%{new}', version '%{old}'. To update to version '%{new}',
destroy and recreate your machine. destroy and recreate your machine.
box_outdated_metadata_error: |-
Error loading box metadata while attempting to check for
updates: %{message}
box_outdated_single: |- box_outdated_single: |-
A newer version of the box '%{name}' is available! You currently A newer version of the box '%{name}' is available! You currently
have version '%{current}'. The latest is version '%{latest}'. Run have version '%{current}'. The latest is version '%{latest}'. Run