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
return @app.call(env)
end
if !env.has_key?(:box_outdated_refresh)
env[:box_outdated_refresh] = true
env[:box_outdated_ignore_errors] = true
end
end
if !machine.box
@ -30,9 +35,17 @@ module Vagrant
end
if env[:box_outdated_refresh]
@logger.info(
"Checking if box is outdated by refreshing metadata")
check_outdated_refresh(env)
env[:ui].output(I18n.t(
"vagrant.box_outdated_checking_with_refresh",
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
@logger.info("Checking if box is outdated locally")
check_outdated_local(env)

View File

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

View File

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