core: BoxCheckOutdated only runs if told to
This commit is contained in:
parent
8cc16d14fa
commit
b5157df2cc
|
@ -24,6 +24,12 @@ module Vagrant
|
|||
def call(env)
|
||||
machine = env[:machine]
|
||||
|
||||
if !env[:box_outdated_force]
|
||||
if !machine.config.vm.box_check_update
|
||||
return @app.call(env)
|
||||
end
|
||||
end
|
||||
|
||||
if !machine.box
|
||||
# The box doesn't exist. I suppose technically that means
|
||||
# that it is "outdated" but we show a specialized error
|
||||
|
@ -55,7 +61,10 @@ module Vagrant
|
|||
old: machine.box.version,
|
||||
new: box.version))
|
||||
env[:box_outdated] = true
|
||||
return
|
||||
end
|
||||
|
||||
env[:box_outdated] = false
|
||||
end
|
||||
|
||||
def check_outdated_refresh(env)
|
||||
|
|
|
@ -26,6 +26,7 @@ module VagrantPlugins
|
|||
|
||||
with_target_vms(argv) do |machine|
|
||||
@env.action_runner.run(Vagrant::Action.action_box_outdated, {
|
||||
box_outdated_force: true,
|
||||
box_outdated_refresh: true,
|
||||
box_outdated_success_ui: true,
|
||||
machine: machine,
|
||||
|
|
|
@ -17,6 +17,7 @@ module VagrantPlugins
|
|||
attr_accessor :base_mac
|
||||
attr_accessor :boot_timeout
|
||||
attr_accessor :box
|
||||
attr_accessor :box_check_update
|
||||
attr_accessor :box_url
|
||||
attr_accessor :box_version
|
||||
attr_accessor :box_download_ca_cert
|
||||
|
@ -33,6 +34,7 @@ module VagrantPlugins
|
|||
def initialize
|
||||
@base_mac = UNSET_VALUE
|
||||
@boot_timeout = UNSET_VALUE
|
||||
@box_check_update = UNSET_VALUE
|
||||
@box_download_ca_cert = UNSET_VALUE
|
||||
@box_download_checksum = UNSET_VALUE
|
||||
@box_download_checksum_type = UNSET_VALUE
|
||||
|
@ -305,6 +307,7 @@ module VagrantPlugins
|
|||
# Defaults
|
||||
@base_mac = nil if @base_mac == UNSET_VALUE
|
||||
@boot_timeout = 300 if @boot_timeout == UNSET_VALUE
|
||||
@box_check_update = nil if @box_check_update == UNSET_VALUE
|
||||
@box_download_ca_cert = nil if @box_download_ca_cert == UNSET_VALUE
|
||||
@box_download_checksum = nil if @box_download_checksum == UNSET_VALUE
|
||||
@box_download_checksum_type = nil if @box_download_checksum_type == UNSET_VALUE
|
||||
|
|
|
@ -32,6 +32,14 @@ describe VagrantPlugins::Kernel_V2::VMConfig do
|
|||
end
|
||||
end
|
||||
|
||||
context "#box_check_update" do
|
||||
it "defaults to nil" do
|
||||
subject.finalize!
|
||||
|
||||
expect(subject.box_check_update).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "#box_url" do
|
||||
it "defaults to nil" do
|
||||
subject.finalize!
|
||||
|
|
|
@ -25,7 +25,38 @@ describe Vagrant::Action::Builtin::BoxCheckOutdated do
|
|||
box_dir = iso_env.box3("foo", "1.0", :virtualbox)
|
||||
Vagrant::Box.new("foo", :virtualbox, "1.0", box_dir)
|
||||
end
|
||||
let(:machine) { iso_vagrant_env.machine(iso_vagrant_env.machine_names[0], :dummy) }
|
||||
let(:machine) do
|
||||
m = iso_vagrant_env.machine(iso_vagrant_env.machine_names[0], :dummy)
|
||||
m.config.vm.box_check_update = true
|
||||
m
|
||||
end
|
||||
|
||||
before do
|
||||
machine.stub(box: box)
|
||||
end
|
||||
|
||||
context "disabling outdated checking" do
|
||||
it "doesn't check" do
|
||||
machine.config.vm.box_check_update = false
|
||||
|
||||
app.should_receive(:call).with(env).once
|
||||
|
||||
subject.call(env)
|
||||
|
||||
expect(env).to_not have_key(:box_outdated)
|
||||
end
|
||||
|
||||
it "checks if forced" do
|
||||
machine.config.vm.box_check_update = false
|
||||
env[:box_outdated_force] = true
|
||||
|
||||
app.should_receive(:call).with(env).once
|
||||
|
||||
subject.call(env)
|
||||
|
||||
expect(env).to have_key(:box_outdated)
|
||||
end
|
||||
end
|
||||
|
||||
context "no box" do
|
||||
it "raises an exception if the machine doesn't have a box yet" do
|
||||
|
|
Loading…
Reference in New Issue