Merge pull request #5283 from mitchellh/sethvargo/developed_on

Add extra metadata information to Atlas pushes
This commit is contained in:
Seth Vargo 2015-02-04 13:29:41 -05:00
commit 2c88f7b7d9
2 changed files with 48 additions and 5 deletions

View File

@ -27,6 +27,7 @@ module VagrantPlugins
cmd << "-vcs" if config.vcs
cmd += config.includes.map { |v| ["-include", v] }
cmd += config.excludes.map { |v| ["-exclude", v] }
cmd += metadata.map { |k,v| ["-metadata", "#{k}=#{v}"] }
cmd += ["-address", config.address] if config.address
cmd += ["-token", config.token] if config.token
cmd << config.app
@ -40,8 +41,7 @@ module VagrantPlugins
# @return [String]
def uploader_path
# Determine the uploader path
uploader = config.uploader_path
if uploader
if uploader = config.uploader_path
return uploader
end
@ -53,6 +53,26 @@ module VagrantPlugins
return Vagrant::Util::Which.which(UPLOADER_BIN)
end
# The metadata command for this push.
#
# @return [Array<String>]
def metadata
box = env.vagrantfile.config.vm.box
box_url = env.vagrantfile.config.vm.box_url
result = {}
if !box.nil? && !box.empty?
result["box"] = box
end
if !box_url.nil? && !box_url.empty?
result["box_url"] = Array(box_url).first
end
return result
end
end
end
end

View File

@ -9,9 +9,9 @@ describe VagrantPlugins::AtlasPush::Push do
let(:bin) { VagrantPlugins::AtlasPush::Push::UPLOADER_BIN }
let(:env) do
double("env",
root_path: File.expand_path("..", __FILE__)
)
iso_env = isolated_environment
iso_env.vagrantfile("")
iso_env.create_vagrant_env
end
let(:config) do
@ -99,6 +99,29 @@ describe VagrantPlugins::AtlasPush::Push do
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
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
describe "#uploader_path" do