Isolate push deprecation to atlas strategy only
This commit is contained in:
parent
e0b9a6fabd
commit
72d0eb497d
|
@ -29,11 +29,11 @@ module Vagrant
|
|||
end
|
||||
alias_method :non_deprecated_execute, :execute
|
||||
|
||||
def execute
|
||||
def execute(*args, &block)
|
||||
@env[:ui].warn(I18n.t("vagrant.commands.deprecated",
|
||||
name: deprecation_command_name
|
||||
) + "\n")
|
||||
non_deprecated_execute
|
||||
non_deprecated_execute(*args, &block)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -44,7 +44,7 @@ module Vagrant
|
|||
def self.included(klass)
|
||||
klass.include(CommandDeprecation)
|
||||
klass.class_eval do
|
||||
def execute
|
||||
def execute(*_)
|
||||
raise Vagrant::Errors::CommandDeprecated,
|
||||
name: deprecation_command_name
|
||||
end
|
||||
|
|
|
@ -70,8 +70,6 @@ module VagrantPlugins
|
|||
|
||||
return name
|
||||
end
|
||||
|
||||
include Vagrant::Util::CommandDeprecation::Complete
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -73,6 +73,12 @@ module VagrantPlugins
|
|||
|
||||
return result
|
||||
end
|
||||
|
||||
include Vagrant::Util::CommandDeprecation::Complete
|
||||
|
||||
def deprecation_command_name
|
||||
"push (atlas strategy)"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,37 +33,35 @@ describe VagrantPlugins::CommandPush::Command do
|
|||
allow(env).to receive(:push)
|
||||
end
|
||||
|
||||
# NOTE: Disabled due to deprecation
|
||||
#
|
||||
# it "validates the pushes" do
|
||||
# expect(subject).to receive(:validate_pushes!).once
|
||||
# subject.execute
|
||||
# end
|
||||
it "validates the pushes" do
|
||||
expect(subject).to receive(:validate_pushes!).once
|
||||
subject.execute
|
||||
end
|
||||
|
||||
# it "delegates to Environment#push" do
|
||||
# expect(env).to receive(:push).once
|
||||
# subject.execute
|
||||
# end
|
||||
it "delegates to Environment#push" do
|
||||
expect(env).to receive(:push).once
|
||||
subject.execute
|
||||
end
|
||||
|
||||
# it "validates the configuration" do
|
||||
# iso_env.vagrantfile <<-EOH
|
||||
# Vagrant.configure("2") do |config|
|
||||
# config.vm.box = "hashicorp/precise64"
|
||||
it "validates the configuration" do
|
||||
iso_env.vagrantfile <<-EOH
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "hashicorp/precise64"
|
||||
|
||||
# config.push.define "noop" do |push|
|
||||
# push.bad = "ham"
|
||||
# end
|
||||
# end
|
||||
# EOH
|
||||
config.push.define "noop" do |push|
|
||||
push.bad = "ham"
|
||||
end
|
||||
end
|
||||
EOH
|
||||
|
||||
# subject = described_class.new(argv, iso_env.create_vagrant_env)
|
||||
# allow(subject).to receive(:validate_pushes!)
|
||||
# .and_return(:noop)
|
||||
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) { |err|
|
||||
# expect(err.message).to include("The following settings shouldn't exist: bad")
|
||||
# }
|
||||
# end
|
||||
expect { subject.execute }.to raise_error(Vagrant::Errors::ConfigInvalid) { |err|
|
||||
expect(err.message).to include("The following settings shouldn't exist: bad")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
describe "#validate_pushes!" do
|
||||
|
|
|
@ -27,154 +27,155 @@ describe VagrantPlugins::AtlasPush::Push do
|
|||
allow(Vagrant::Util::SafeExec).to receive(:exec)
|
||||
end
|
||||
|
||||
describe "#push" do
|
||||
it "pushes with the uploader" do
|
||||
allow(subject).to receive(:uploader_path).and_return("foo")
|
||||
# DEPRECATED
|
||||
# describe "#push" do
|
||||
# it "pushes with the uploader" do
|
||||
# allow(subject).to receive(:uploader_path).and_return("foo")
|
||||
|
||||
expect(subject).to receive(:execute).with("foo")
|
||||
# expect(subject).to receive(:execute).with("foo")
|
||||
|
||||
subject.push
|
||||
end
|
||||
# subject.push
|
||||
# end
|
||||
|
||||
it "raises an exception if the uploader couldn't be found" do
|
||||
expect(subject).to receive(:uploader_path).and_return(nil)
|
||||
# it "raises an exception if the uploader couldn't be found" do
|
||||
# expect(subject).to receive(:uploader_path).and_return(nil)
|
||||
|
||||
expect { subject.push }.to raise_error(
|
||||
VagrantPlugins::AtlasPush::Errors::UploaderNotFound)
|
||||
end
|
||||
end
|
||||
# expect { subject.push }.to raise_error(
|
||||
# VagrantPlugins::AtlasPush::Errors::UploaderNotFound)
|
||||
# end
|
||||
# end
|
||||
|
||||
describe "#execute" do
|
||||
let(:app) { "foo/bar" }
|
||||
# describe "#execute" do
|
||||
# let(:app) { "foo/bar" }
|
||||
|
||||
before do
|
||||
config.app = app
|
||||
end
|
||||
# before do
|
||||
# config.app = app
|
||||
# end
|
||||
|
||||
it "sends the basic flags" do
|
||||
expect(Vagrant::Util::SafeExec).to receive(:exec).
|
||||
with("foo", "-vcs", app, env.root_path.to_s)
|
||||
# it "sends the basic flags" do
|
||||
# expect(Vagrant::Util::SafeExec).to receive(:exec).
|
||||
# with("foo", "-vcs", app, env.root_path.to_s)
|
||||
|
||||
subject.execute("foo")
|
||||
end
|
||||
# subject.execute("foo")
|
||||
# end
|
||||
|
||||
it "doesn't send VCS if disabled" do
|
||||
expect(Vagrant::Util::SafeExec).to receive(:exec).
|
||||
with("foo", app, env.root_path.to_s)
|
||||
# it "doesn't send VCS if disabled" do
|
||||
# expect(Vagrant::Util::SafeExec).to receive(:exec).
|
||||
# with("foo", app, env.root_path.to_s)
|
||||
|
||||
config.vcs = false
|
||||
subject.execute("foo")
|
||||
end
|
||||
# config.vcs = false
|
||||
# subject.execute("foo")
|
||||
# end
|
||||
|
||||
it "sends includes" do
|
||||
expect(Vagrant::Util::SafeExec).to receive(:exec).
|
||||
with("foo", "-vcs", "-include", "foo", "-include",
|
||||
"bar", app, env.root_path.to_s)
|
||||
# it "sends includes" do
|
||||
# expect(Vagrant::Util::SafeExec).to receive(:exec).
|
||||
# with("foo", "-vcs", "-include", "foo", "-include",
|
||||
# "bar", app, env.root_path.to_s)
|
||||
|
||||
config.includes = ["foo", "bar"]
|
||||
subject.execute("foo")
|
||||
end
|
||||
# config.includes = ["foo", "bar"]
|
||||
# subject.execute("foo")
|
||||
# end
|
||||
|
||||
it "sends excludes" do
|
||||
expect(Vagrant::Util::SafeExec).to receive(:exec).
|
||||
with("foo", "-vcs", "-exclude", "foo", "-exclude",
|
||||
"bar", app, env.root_path.to_s)
|
||||
# it "sends excludes" do
|
||||
# expect(Vagrant::Util::SafeExec).to receive(:exec).
|
||||
# with("foo", "-vcs", "-exclude", "foo", "-exclude",
|
||||
# "bar", app, env.root_path.to_s)
|
||||
|
||||
config.excludes = ["foo", "bar"]
|
||||
subject.execute("foo")
|
||||
end
|
||||
# config.excludes = ["foo", "bar"]
|
||||
# subject.execute("foo")
|
||||
# end
|
||||
|
||||
it "sends custom server address" do
|
||||
expect(Vagrant::Util::SafeExec).to receive(:exec).
|
||||
with("foo", "-vcs", "-address", "foo", app, env.root_path.to_s)
|
||||
# it "sends custom server address" do
|
||||
# expect(Vagrant::Util::SafeExec).to receive(:exec).
|
||||
# with("foo", "-vcs", "-address", "foo", app, env.root_path.to_s)
|
||||
|
||||
config.address = "foo"
|
||||
subject.execute("foo")
|
||||
end
|
||||
# config.address = "foo"
|
||||
# subject.execute("foo")
|
||||
# end
|
||||
|
||||
it "sends custom token" do
|
||||
expect(Vagrant::Util::SafeExec).to receive(:exec).
|
||||
with("foo", "-vcs", "-token", "atlas_token", app, env.root_path.to_s)
|
||||
# it "sends custom token" do
|
||||
# expect(Vagrant::Util::SafeExec).to receive(:exec).
|
||||
# with("foo", "-vcs", "-token", "atlas_token", app, env.root_path.to_s)
|
||||
|
||||
config.token = "atlas_token"
|
||||
subject.execute("foo")
|
||||
end
|
||||
# config.token = "atlas_token"
|
||||
# subject.execute("foo")
|
||||
# end
|
||||
|
||||
context "when metadata is available" do
|
||||
let(:env) do
|
||||
iso_env = isolated_environment
|
||||
iso_env.vagrantfile <<-EOH
|
||||
Vagrant.configure("2") do |config|
|
||||
config.vm.box = "hashicorp/precise64"
|
||||
config.vm.box_url = "https://atlas.hashicorp.com/hashicorp/precise64"
|
||||
end
|
||||
EOH
|
||||
iso_env.create_vagrant_env
|
||||
end
|
||||
# context "when metadata is available" do
|
||||
# let(:env) do
|
||||
# iso_env = isolated_environment
|
||||
# iso_env.vagrantfile <<-EOH
|
||||
# Vagrant.configure("2") do |config|
|
||||
# config.vm.box = "hashicorp/precise64"
|
||||
# config.vm.box_url = "https://atlas.hashicorp.com/hashicorp/precise64"
|
||||
# end
|
||||
# EOH
|
||||
# iso_env.create_vagrant_env
|
||||
# end
|
||||
|
||||
it "sends the metadata" do
|
||||
expect(Vagrant::Util::SafeExec).to receive(:exec).
|
||||
with("foo", "-vcs", "-metadata", "box=hashicorp/precise64",
|
||||
"-metadata", "box_url=https://atlas.hashicorp.com/hashicorp/precise64",
|
||||
"-token", "atlas_token", app, env.root_path.to_s)
|
||||
# it "sends the metadata" do
|
||||
# expect(Vagrant::Util::SafeExec).to receive(:exec).
|
||||
# with("foo", "-vcs", "-metadata", "box=hashicorp/precise64",
|
||||
# "-metadata", "box_url=https://atlas.hashicorp.com/hashicorp/precise64",
|
||||
# "-token", "atlas_token", app, env.root_path.to_s)
|
||||
|
||||
config.token = "atlas_token"
|
||||
subject.execute("foo")
|
||||
end
|
||||
end
|
||||
end
|
||||
# config.token = "atlas_token"
|
||||
# subject.execute("foo")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
|
||||
describe "#uploader_path" do
|
||||
let(:scratch) do
|
||||
Pathname.new(Dir.mktmpdir("vagrant-test-atlas-push-upload-path"))
|
||||
end
|
||||
# describe "#uploader_path" do
|
||||
# let(:scratch) do
|
||||
# Pathname.new(Dir.mktmpdir("vagrant-test-atlas-push-upload-path"))
|
||||
# end
|
||||
|
||||
after do
|
||||
FileUtils.rm_rf(scratch)
|
||||
end
|
||||
# after do
|
||||
# FileUtils.rm_rf(scratch)
|
||||
# end
|
||||
|
||||
it "should return the configured path if set" do
|
||||
config.uploader_path = "foo"
|
||||
expect(subject.uploader_path).to eq("foo")
|
||||
end
|
||||
# it "should return the configured path if set" do
|
||||
# config.uploader_path = "foo"
|
||||
# expect(subject.uploader_path).to eq("foo")
|
||||
# end
|
||||
|
||||
it "should look up the uploader via PATH if not set" do
|
||||
allow(Vagrant).to receive(:in_installer?).and_return(false)
|
||||
# it "should look up the uploader via PATH if not set" do
|
||||
# allow(Vagrant).to receive(:in_installer?).and_return(false)
|
||||
|
||||
expect(Vagrant::Util::Which).to receive(:which).
|
||||
with(described_class.const_get(:UPLOADER_BIN)).
|
||||
and_return("bar")
|
||||
# expect(Vagrant::Util::Which).to receive(:which).
|
||||
# with(described_class.const_get(:UPLOADER_BIN)).
|
||||
# and_return("bar")
|
||||
|
||||
expect(subject.uploader_path).to eq("bar")
|
||||
end
|
||||
# expect(subject.uploader_path).to eq("bar")
|
||||
# end
|
||||
|
||||
it "should look up the uploader in the embedded dir if installer" do
|
||||
allow(Vagrant).to receive(:in_installer?).and_return(true)
|
||||
allow(Vagrant).to receive(:installer_embedded_dir).and_return(scratch.to_s)
|
||||
# it "should look up the uploader in the embedded dir if installer" do
|
||||
# allow(Vagrant).to receive(:in_installer?).and_return(true)
|
||||
# allow(Vagrant).to receive(:installer_embedded_dir).and_return(scratch.to_s)
|
||||
|
||||
bin_path = scratch.join("bin", bin)
|
||||
bin_path.dirname.mkpath
|
||||
bin_path.open("w+") { |f| f.write("hi") }
|
||||
# bin_path = scratch.join("bin", bin)
|
||||
# bin_path.dirname.mkpath
|
||||
# bin_path.open("w+") { |f| f.write("hi") }
|
||||
|
||||
expect(subject.uploader_path).to eq(bin_path.to_s)
|
||||
end
|
||||
# expect(subject.uploader_path).to eq(bin_path.to_s)
|
||||
# end
|
||||
|
||||
it "should look up the uploader in the PATH if not in the installer" do
|
||||
allow(Vagrant).to receive(:in_installer?).and_return(true)
|
||||
allow(Vagrant).to receive(:installer_embedded_dir).and_return(scratch.to_s)
|
||||
# it "should look up the uploader in the PATH if not in the installer" do
|
||||
# allow(Vagrant).to receive(:in_installer?).and_return(true)
|
||||
# allow(Vagrant).to receive(:installer_embedded_dir).and_return(scratch.to_s)
|
||||
|
||||
expect(Vagrant::Util::Which).to receive(:which).
|
||||
with(described_class.const_get(:UPLOADER_BIN)).
|
||||
and_return("bar")
|
||||
# expect(Vagrant::Util::Which).to receive(:which).
|
||||
# with(described_class.const_get(:UPLOADER_BIN)).
|
||||
# and_return("bar")
|
||||
|
||||
expect(subject.uploader_path).to eq("bar")
|
||||
end
|
||||
# expect(subject.uploader_path).to eq("bar")
|
||||
# end
|
||||
|
||||
it "should return nil if its not found anywhere" do
|
||||
allow(Vagrant).to receive(:in_installer?).and_return(false)
|
||||
allow(Vagrant::Util::Which).to receive(:which).and_return(nil)
|
||||
# it "should return nil if its not found anywhere" do
|
||||
# allow(Vagrant).to receive(:in_installer?).and_return(false)
|
||||
# allow(Vagrant::Util::Which).to receive(:which).and_return(nil)
|
||||
|
||||
expect(subject.uploader_path).to be_nil
|
||||
end
|
||||
end
|
||||
# expect(subject.uploader_path).to be_nil
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue