extend the omnibus command builder with an additional download_path parameter
This commit is contained in:
parent
9e7f705bad
commit
d7bd65b4e2
|
@ -5,10 +5,10 @@ module VagrantPlugins
|
||||||
|
|
||||||
# Read more about the Omnibus installer here:
|
# Read more about the Omnibus installer here:
|
||||||
# https://docs.getchef.com/install_omnibus.html
|
# https://docs.getchef.com/install_omnibus.html
|
||||||
def build_command(version, prerelease = false)
|
def build_command(version, prerelease = false, download_path = nil)
|
||||||
command = "curl -sL #{OMNITRUCK} | sudo bash"
|
command = "curl -sL #{OMNITRUCK} | sudo bash"
|
||||||
|
|
||||||
if prerelease || version != :latest
|
if prerelease || version != :latest || download_path != nil
|
||||||
command << " -s --"
|
command << " -s --"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -20,6 +20,10 @@ module VagrantPlugins
|
||||||
command << " -v \"#{version}\""
|
command << " -v \"#{version}\""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if download_path
|
||||||
|
command << " -d \"#{download_path}\""
|
||||||
|
end
|
||||||
|
|
||||||
command
|
command
|
||||||
end
|
end
|
||||||
module_function :build_command
|
module_function :build_command
|
||||||
|
|
|
@ -7,8 +7,9 @@ describe VagrantPlugins::Chef::Omnibus, :focus do
|
||||||
|
|
||||||
let(:version) { :latest }
|
let(:version) { :latest }
|
||||||
let(:prerelease) { false }
|
let(:prerelease) { false }
|
||||||
|
let(:download_path) { nil }
|
||||||
|
|
||||||
let(:build_command) { described_class.build_command(version, prerelease) }
|
let(:build_command) { described_class.build_command(version, prerelease, download_path) }
|
||||||
|
|
||||||
context "when prerelease is given" do
|
context "when prerelease is given" do
|
||||||
let(:prerelease) { true }
|
let(:prerelease) { true }
|
||||||
|
@ -18,6 +19,14 @@ describe VagrantPlugins::Chef::Omnibus, :focus do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "when download_path is given" do
|
||||||
|
let(:download_path) { '/tmp/path/to/omnibuses' }
|
||||||
|
|
||||||
|
it "returns the correct command" do
|
||||||
|
expect(build_command).to eq("#{prefix} | sudo bash -s -- -d \"/tmp/path/to/omnibuses\"")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "when version is :latest" do
|
context "when version is :latest" do
|
||||||
let(:version) { :latest }
|
let(:version) { :latest }
|
||||||
|
|
||||||
|
@ -34,12 +43,13 @@ describe VagrantPlugins::Chef::Omnibus, :focus do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when prerelease and version are given" do
|
context "when prerelease and version and download_path are given" do
|
||||||
let(:version) { "1.2.3" }
|
let(:version) { "1.2.3" }
|
||||||
let(:prerelease) { true }
|
let(:prerelease) { true }
|
||||||
|
let(:download_path) { "/some/path" }
|
||||||
|
|
||||||
it "returns the correct command" do
|
it "returns the correct command" do
|
||||||
expect(build_command).to eq("#{prefix} | sudo bash -s -- -p -v \"1.2.3\"")
|
expect(build_command).to eq("#{prefix} | sudo bash -s -- -p -v \"1.2.3\" -d \"/some/path\"")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue