core: output the expanded URL

This commit is contained in:
Mitchell Hashimoto 2014-01-23 22:40:12 -08:00
parent 5aba445cac
commit 1bd3275b3b
2 changed files with 13 additions and 8 deletions

View File

@ -29,13 +29,12 @@ module Vagrant
uri = URI.parse(url) uri = URI.parse(url)
if !uri.scheme && !File.file?(url) if !uri.scheme && !File.file?(url)
url = "#{Vagrant.server_url}/#{url}" url = "#{Vagrant.server_url}/#{url}"
env[:box_url] = url
end end
if metadata_url?(url, env) if metadata_url?(url, env)
add_from_metadata(env) add_from_metadata(url, env)
else else
add_direct(env) add_direct(url, env)
end end
@app.call(env) @app.call(env)
@ -43,13 +42,12 @@ module Vagrant
# Adds a box file directly (no metadata component, versioning, # Adds a box file directly (no metadata component, versioning,
# etc.) # etc.)
def add_direct(env) def add_direct(url, env)
name = env[:box_name] name = env[:box_name]
if !name || name == "" if !name || name == ""
raise Errors::BoxAddNameRequired raise Errors::BoxAddNameRequired
end end
url = env[:box_url]
provider = env[:box_provider] provider = env[:box_provider]
provider = Array(provider) if provider provider = Array(provider) if provider
@ -62,14 +60,19 @@ module Vagrant
end end
# Adds a box given that the URL is a metadata document. # Adds a box given that the URL is a metadata document.
def add_from_metadata(env) def add_from_metadata(url, env)
original_url = env[:box_url]
provider = env[:box_provider] provider = env[:box_provider]
provider = Array(provider) if provider provider = Array(provider) if provider
url = env[:box_url]
version = env[:box_version] version = env[:box_version]
env[:ui].output(I18n.t( env[:ui].output(I18n.t(
"vagrant.box_loading_metadata", name: url)) "vagrant.box_loading_metadata", name: original_url))
if original_url != url
env[:ui].detail(I18n.t(
"vagrant.box_expanding_url", url: url))
end
metadata = nil metadata = nil
begin begin
metadata_path = download(url, env, ui: false) metadata_path = download(url, env, ui: false)

View File

@ -18,6 +18,8 @@ en:
Adding box '%{name}' (v%{version}) for '%{provider}' provider... Adding box '%{name}' (v%{version}) for '%{provider}' provider...
box_added: |- box_added: |-
Successfully added box '%{name}' for '%{provider}'! Successfully added box '%{name}' for '%{provider}'!
box_expanding_url: |-
URL: %{url}
box_loading_metadata: |- box_loading_metadata: |-
Loading metadata for box '%{name}' Loading metadata for box '%{name}'
cfengine_bootstrapping: |- cfengine_bootstrapping: |-