2014-01-24 22:14:05 +00:00
|
|
|
require 'optparse'
|
|
|
|
|
Add HTTPS download options to `box update` and `box outdated`
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
2014-09-08 03:45:32 +00:00
|
|
|
require_relative 'download_mixins'
|
|
|
|
|
2014-01-24 22:14:05 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module CommandBox
|
|
|
|
module Command
|
|
|
|
class Outdated < Vagrant.plugin("2", :command)
|
Add HTTPS download options to `box update` and `box outdated`
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
2014-09-08 03:45:32 +00:00
|
|
|
include DownloadMixins
|
|
|
|
|
2014-01-24 22:14:05 +00:00
|
|
|
def execute
|
2014-01-24 22:50:55 +00:00
|
|
|
options = {}
|
Add HTTPS download options to `box update` and `box outdated`
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
2014-09-08 03:45:32 +00:00
|
|
|
download_options = {}
|
2014-01-24 22:50:55 +00:00
|
|
|
|
|
|
|
opts = OptionParser.new do |o|
|
2014-01-25 01:52:52 +00:00
|
|
|
o.banner = "Usage: vagrant box outdated [options]"
|
|
|
|
o.separator ""
|
|
|
|
o.separator "Checks if there is a new version available for the box"
|
|
|
|
o.separator "that are you are using. If you pass in the --global flag,"
|
|
|
|
o.separator "all boxes will be checked for updates."
|
|
|
|
o.separator ""
|
|
|
|
o.separator "Options:"
|
2014-01-24 22:50:55 +00:00
|
|
|
o.separator ""
|
|
|
|
|
2014-02-08 08:20:50 +00:00
|
|
|
o.on("--global", "Check all boxes installed") do |g|
|
2014-01-24 22:50:55 +00:00
|
|
|
options[:global] = g
|
|
|
|
end
|
Add HTTPS download options to `box update` and `box outdated`
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
2014-09-08 03:45:32 +00:00
|
|
|
|
|
|
|
build_download_options(o, download_options)
|
2014-01-24 22:50:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
argv = parse_options(opts)
|
2014-01-25 01:52:52 +00:00
|
|
|
return if !argv
|
2014-01-24 22:50:55 +00:00
|
|
|
|
|
|
|
# If we're checking the boxes globally, then do that.
|
|
|
|
if options[:global]
|
Add HTTPS download options to `box update` and `box outdated`
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
2014-09-08 03:45:32 +00:00
|
|
|
outdated_global(download_options)
|
2014-01-24 22:50:55 +00:00
|
|
|
return 0
|
2014-01-24 22:14:05 +00:00
|
|
|
end
|
|
|
|
|
2014-01-24 22:50:55 +00:00
|
|
|
with_target_vms(argv) do |machine|
|
|
|
|
@env.action_runner.run(Vagrant::Action.action_box_outdated, {
|
2014-01-24 23:27:01 +00:00
|
|
|
box_outdated_force: true,
|
2014-01-24 22:50:55 +00:00
|
|
|
box_outdated_refresh: true,
|
2014-01-24 22:56:41 +00:00
|
|
|
box_outdated_success_ui: true,
|
2014-01-24 22:50:55 +00:00
|
|
|
machine: machine,
|
Add HTTPS download options to `box update` and `box outdated`
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
2014-09-08 03:45:32 +00:00
|
|
|
}.merge(download_options))
|
2014-01-24 22:50:55 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
Add HTTPS download options to `box update` and `box outdated`
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
2014-09-08 03:45:32 +00:00
|
|
|
def outdated_global(download_options)
|
2014-01-24 22:14:05 +00:00
|
|
|
boxes = {}
|
|
|
|
@env.boxes.all.reverse.each do |name, version, provider|
|
|
|
|
next if boxes[name]
|
|
|
|
boxes[name] = @env.boxes.find(name, provider, version)
|
|
|
|
end
|
|
|
|
|
|
|
|
boxes.values.each do |box|
|
|
|
|
if !box.metadata_url
|
|
|
|
@env.ui.output(I18n.t(
|
|
|
|
"vagrant.box_outdated_no_metadata",
|
|
|
|
name: box.name))
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
|
|
|
md = nil
|
|
|
|
begin
|
Add HTTPS download options to `box update` and `box outdated`
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
2014-09-08 03:45:32 +00:00
|
|
|
md = box.load_metadata(download_options)
|
2015-11-20 02:50:39 +00:00
|
|
|
rescue Vagrant::Errors::BoxMetadataDownloadError => e
|
2014-01-24 22:14:05 +00:00
|
|
|
@env.ui.error(I18n.t(
|
|
|
|
"vagrant.box_outdated_metadata_error",
|
|
|
|
name: box.name,
|
|
|
|
message: e.extra_data[:message]))
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
|
|
|
current = Gem::Version.new(box.version)
|
|
|
|
latest = Gem::Version.new(md.versions.last)
|
|
|
|
if latest <= current
|
|
|
|
@env.ui.success(I18n.t(
|
|
|
|
"vagrant.box_up_to_date",
|
|
|
|
name: box.name,
|
|
|
|
version: box.version))
|
|
|
|
else
|
|
|
|
@env.ui.warn(I18n.t(
|
|
|
|
"vagrant.box_outdated",
|
|
|
|
name: box.name,
|
|
|
|
current: box.version,
|
|
|
|
latest: latest.to_s,))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|