Add "--insecure" flag for downloader

This commit is contained in:
Mitchell Hashimoto 2013-04-03 11:57:40 -07:00
parent 58b7c65a69
commit 5e2549fe8b
6 changed files with 40 additions and 5 deletions

View File

@ -1,5 +1,6 @@
Vagrant.configure("2") do |config|
# default config goes here
config.downloader.insecure = false
config.vagrant.host = :detect
config.ssh.username = "vagrant"

View File

@ -24,12 +24,16 @@ module Vagrant
url = "file:#{url}"
end
downloader_options = {}
downloader_options[:insecure] = env[:box_download_insecure]
downloader_options[:ui] = env[:ui]
# Download the box to a temporary path. We store the temporary
# path as an instance variable so that the `#recover` method can
# access it.
env[:ui].info(I18n.t("vagrant.actions.box.download.downloading"))
begin
downloader = Util::Downloader.new(url, @temp_path, :ui => env[:ui])
downloader = Util::Downloader.new(url, @temp_path, downloader_options)
downloader.download!
rescue Errors::DownloaderInterrupted
# The downloader was interrupted, so just return, because that

View File

@ -16,6 +16,7 @@ module Vagrant
# Get the various optional values
options ||= {}
@insecure = options[:insecure]
@ui = options[:ui]
end
@ -29,10 +30,12 @@ module Vagrant
# Build the list of parameters to execute with cURL
options = [
"--fail",
"--output", @destination,
@source
"--output", @destination
]
options << "--insecure" if @insecure
options << @source
# This variable can contain the proc that'll be sent to
# the subprocess execute.
data_proc = nil

View File

@ -15,6 +15,10 @@ module VagrantPlugins
options[:force] = f
end
o.on("--insecure", "If set, SSL certs will not be validated.") do |i|
options[:insecure] = i
end
o.on("--provider provider", String,
"The provider that backs the box.") do |p|
options[:provider] = p
@ -34,7 +38,8 @@ module VagrantPlugins
:box_name => argv[0],
:box_provider => provider,
:box_url => argv[1],
:box_force => options[:force]
:box_force => options[:force],
:box_download_insecure => options[:insecure],
})
# Success, exit status 0

View File

@ -0,0 +1,17 @@
module VagrantPlugins
module Kernel_V2
class DownloaderConfig < Vagrant.plugin("2", :config)
attr_accessor :insecure
def initialize
super
@insecure = UNSET_VALUE
end
def finalize!
@insecure = false if @insecure == UNSET_VALUE
end
end
end
end

View File

@ -15,6 +15,11 @@ module VagrantPlugins
# "kernel_v1", none of these configuration classes are upgradable.
# This is by design, since we can't be sure if they're upgradable
# until another version is available.
config("downloader") do
require File.expand_path("../config/downloader", __FILE__)
DownloaderConfig
end
config("ssh") do
require File.expand_path("../config/ssh", __FILE__)
SSHConfig