diff options
author | sersut <serdar@opscode.com> | 2014-05-12 14:14:40 -0700 |
---|---|---|
committer | sersut <serdar@opscode.com> | 2014-05-12 14:14:40 -0700 |
commit | fed691961da49250e88803743ed0450234d1aa30 (patch) | |
tree | 2e13dc0db9750f87186f5df9795a6390cac4b669 | |
parent | 54f47c478ab1b4bee0775b61ca59dda17a818e0a (diff) | |
download | chef-fed691961da49250e88803743ed0450234d1aa30.tar.gz |
Use the :bootstrap_version if set by the user.
-rw-r--r-- | lib/chef/knife/core/bootstrap_context.rb | 15 | ||||
-rw-r--r-- | spec/unit/knife/core/bootstrap_context_spec.rb | 32 |
2 files changed, 45 insertions, 2 deletions
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index fc7b41d283..742ef226a3 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -114,7 +114,20 @@ CONFIG # If user is on X.Y.Z bootstrap will use the latest X release # X here can be 10 or 11 def latest_current_chef_version_string - "-v #{chef_version.split(".").first}" + chef_version_string = if knife_config[:bootstrap_version] + knife_config[:bootstrap_version] + else + Chef::VERSION.split(".").first + end + + installer_version_string = ["-v", chef_version_string] + + # If bootstrapping a pre-release version add -p to the installer string + if chef_version_string.split(".").length > 3 + installer_version_string << "-p" + end + + installer_version_string.join(" ") end def first_boot diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb index 17e265edad..9cabc59719 100644 --- a/spec/unit/knife/core/bootstrap_context_spec.rb +++ b/spec/unit/knife/core/bootstrap_context_spec.rb @@ -166,5 +166,35 @@ EXPECTED end end end -end + describe "when a bootstrap_version is specified" do + let(:chef_config) do + { + :knife => {:bootstrap_version => "11.12.4" } + } + end + + it "should send the full version to the installer" do + bootstrap_context.latest_current_chef_version_string.should eq("-v 11.12.4") + end + end + + describe "when a pre-release bootstrap_version is specified" do + let(:chef_config) do + { + :knife => {:bootstrap_version => "11.12.4.rc.0" } + } + end + + it "should send the full version to the installer and set the pre-release flag" do + bootstrap_context.latest_current_chef_version_string.should eq("-v 11.12.4.rc.0 -p") + end + end + + describe "when a bootstrap_version is not specified" do + it "should send the latest current to the installer" do + # Intentionally hard coded in order not to replicate the logic. + bootstrap_context.latest_current_chef_version_string.should eq("-v 11") + end + end +end |