commands/push: validate configuration
/cc @sethvargo - Some weirdness here but overall should work fine. I'm not sure if there was a GH issue this should be attached to or close. To explain: We just use the first machine with the default provider. A Vagrant::Environment guarantees there is at least one machine, so `env.machine_names.first` will always work. And we can just use the default provider because we don't really care. Finally, it can be any old machine we pass in because we just want the "global" config to validate and there is no way to say "don't validate machine-specific configs", so we might as well just pick the first machine to validate.
This commit is contained in:
parent
c142ff29b2
commit
5903bfb3c6
|
@ -8,8 +8,10 @@ BUG FIXES:
|
|||
|
||||
- core: private boxes still referencing vagrantcloud.com will have
|
||||
their vagrant login access token properly appended
|
||||
- core: push plugin configuration is properly validated
|
||||
- commands/push: push lookups are by user-defined name, not push
|
||||
strategy name [GH-4975]
|
||||
- commands/push: validate the configuration
|
||||
- guests/arch: fix network configuration due to poor line breaks. [GH-4964]
|
||||
- provisioners/chef: remove Chef version check from solo.rb generation and
|
||||
make `roles_path` populate correctly
|
||||
|
|
|
@ -19,6 +19,11 @@ module VagrantPlugins
|
|||
|
||||
name = validate_pushes!(@env.pushes, argv[0])
|
||||
|
||||
# Validate the configuration
|
||||
@env.machine(@env.machine_names.first, @env.default_provider).action_raw(
|
||||
:config_validate,
|
||||
Vagrant::Action::Builtin::ConfigValidate)
|
||||
|
||||
@logger.debug("'push' environment with strategy: `#{name}'")
|
||||
@env.push(name)
|
||||
|
||||
|
|
|
@ -6,11 +6,14 @@ describe VagrantPlugins::CommandPush::Command do
|
|||
include_context "unit"
|
||||
include_context "command plugin helpers"
|
||||
|
||||
let(:iso_env) { isolated_environment }
|
||||
let(:env) do
|
||||
isolated_environment.tap do |env|
|
||||
env.vagrantfile("")
|
||||
env.create_vagrant_env
|
||||
end
|
||||
iso_env.vagrantfile(<<-VF)
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "nope"
|
||||
end
|
||||
VF
|
||||
iso_env.create_vagrant_env
|
||||
end
|
||||
|
||||
let(:argv) { [] }
|
||||
|
@ -35,6 +38,17 @@ describe VagrantPlugins::CommandPush::Command do
|
|||
subject.execute
|
||||
end
|
||||
|
||||
it "validates the configuration" do
|
||||
iso_env.vagrantfile("")
|
||||
|
||||
subject = described_class.new(argv, iso_env.create_vagrant_env)
|
||||
allow(subject).to receive(:validate_pushes!)
|
||||
.and_return(:noop)
|
||||
|
||||
expect { subject.execute }.to raise_error(
|
||||
Vagrant::Errors::ConfigInvalid)
|
||||
end
|
||||
|
||||
it "delegates to Environment#push" do
|
||||
expect(env).to receive(:push).once
|
||||
subject.execute
|
||||
|
|
Loading…
Reference in New Issue