Vagrant::Box.load_metadata did not provide a way to specify the HTTPS download options that could be specified when downloading boxes (ca cert, ca path, client cert, insecure). As a result, while it was possible to add a box whose metadata file needed to be downloaded with one of those options specified, it was impossible to check for updates. The following changes have been made to address the situation: 1. Create a DownloadMixins module to provide the --insecure, --cacert, --capth, and --cert command line options to all of `vagrant box add`, `vagrant box update`, and `vagrant box outdated`. 2. Extend `Vagrant::Box.has_update?` and `Vagrant::Box.load_metadata` to accept said download options. 3. Extend `box outdated` and `box update` commands to pass download options down. 4. Extend `Vagrant::Builtin::Action::BoxCheckOutdated` to honour download options. 5. Options specified on the command line take precedence over options specified in the machine configuration, if any. 6. Fix bug in `vagrant box add` where client cert was being passed down using the wrong environment key. 7. Unit test coverage in update_test and box_check_outdated_test. Resolves #4420
30 lines
901 B
Ruby
30 lines
901 B
Ruby
module VagrantPlugins
|
|
module CommandBox
|
|
module DownloadMixins
|
|
# This adds common download command line flags to the given
|
|
# OptionParser, storing the result in the `options` dictionary.
|
|
#
|
|
# @param [OptionParser] parser
|
|
# @param [Hash] options
|
|
def build_download_options(parser, options)
|
|
# Add the options
|
|
parser.on("--insecure", "Do not validate SSL certificates") do |i|
|
|
options[:insecure] = i
|
|
end
|
|
|
|
parser.on("--cacert FILE", String, "CA certificate for SSL download") do |c|
|
|
options[:ca_cert] = c
|
|
end
|
|
|
|
parser.on("--capath DIR", String, "CA certificate directory for SSL download") do |c|
|
|
options[:ca_path] = c
|
|
end
|
|
|
|
parser.on("--cert FILE", String, "A client SSL cert, if needed") do |c|
|
|
options[:client_cert] = c
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|