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| Vagrant.configure("2") do |config|
# default config goes here config.downloader.insecure = false
config.vagrant.host = :detect config.vagrant.host = :detect
config.ssh.username = "vagrant" config.ssh.username = "vagrant"

View File

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

View File

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

View File

@ -15,6 +15,10 @@ module VagrantPlugins
options[:force] = f options[:force] = f
end end
o.on("--insecure", "If set, SSL certs will not be validated.") do |i|
options[:insecure] = i
end
o.on("--provider provider", String, o.on("--provider provider", String,
"The provider that backs the box.") do |p| "The provider that backs the box.") do |p|
options[:provider] = p options[:provider] = p
@ -34,7 +38,8 @@ module VagrantPlugins
:box_name => argv[0], :box_name => argv[0],
:box_provider => provider, :box_provider => provider,
:box_url => argv[1], :box_url => argv[1],
:box_force => options[:force] :box_force => options[:force],
:box_download_insecure => options[:insecure],
}) })
# Success, exit status 0 # 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. # "kernel_v1", none of these configuration classes are upgradable.
# This is by design, since we can't be sure if they're upgradable # This is by design, since we can't be sure if they're upgradable
# until another version is available. # until another version is available.
config("downloader") do
require File.expand_path("../config/downloader", __FILE__)
DownloaderConfig
end
config("ssh") do config("ssh") do
require File.expand_path("../config/ssh", __FILE__) require File.expand_path("../config/ssh", __FILE__)
SSHConfig SSHConfig