diff --git a/CHANGELOG.md b/CHANGELOG.md index e5901fa74..802d2b209 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/plugins/commands/push/command.rb b/plugins/commands/push/command.rb index dabe74bb6..902a0c946 100644 --- a/plugins/commands/push/command.rb +++ b/plugins/commands/push/command.rb @@ -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) diff --git a/test/unit/plugins/commands/push/command_test.rb b/test/unit/plugins/commands/push/command_test.rb index 06995d51d..0f649c6c4 100644 --- a/test/unit/plugins/commands/push/command_test.rb +++ b/test/unit/plugins/commands/push/command_test.rb @@ -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