diff options
author | Marc A. Paradise <marc.paradise@gmail.com> | 2019-04-30 17:44:48 -0400 |
---|---|---|
committer | Marc A. Paradise <marc.paradise@gmail.com> | 2019-05-03 17:30:07 -0400 |
commit | ba50ae6d20ef86ab39b9fa2eee982f929cd70c7e (patch) | |
tree | 56f5d03eef665e65fa6611ee236cc52bb59a9c97 /lib/chef/knife/core | |
parent | 58db2c3f47e86d539d21f9365adb135726719e38 (diff) | |
download | chef-ba50ae6d20ef86ab39b9fa2eee982f929cd70c7e.tar.gz |
Restore bootstrap pre-release support
It was originally removed after discussion in community slack,
but it turns out to have a little more utility than we thought.
When enabled, it will cause the package to be downloaded from
the `current` channel.
Option description has been updated from 'install prerelease gem'
to 'install from current channel'.
This commit otherwise restores the original behavior and adds some tests.
Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
Diffstat (limited to 'lib/chef/knife/core')
-rw-r--r-- | lib/chef/knife/core/bootstrap_context.rb | 23 | ||||
-rw-r--r-- | lib/chef/knife/core/windows_bootstrap_context.rb | 24 |
2 files changed, 35 insertions, 12 deletions
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb index dcca7b8a69..c46a6bc079 100644 --- a/lib/chef/knife/core/bootstrap_context.rb +++ b/lib/chef/knife/core/bootstrap_context.rb @@ -190,13 +190,24 @@ class Chef # chef version string to fetch the latest current version from omnitruck # If user is on X.Y.Z, bootstrap will use the latest X release def latest_current_chef_version_string - chef_version_string = if knife_config[:bootstrap_version] - knife_config[:bootstrap_version] - else - Chef::VERSION.split(".").first - end + installer_version_string = nil + if @config[:prerelease] + installer_version_string = ["-p"] + else + 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] - "-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 + end + installer_version_string.join(" ") end def first_boot diff --git a/lib/chef/knife/core/windows_bootstrap_context.rb b/lib/chef/knife/core/windows_bootstrap_context.rb index 6054743106..c6b8bc4d2b 100644 --- a/lib/chef/knife/core/windows_bootstrap_context.rb +++ b/lib/chef/knife/core/windows_bootstrap_context.rb @@ -159,13 +159,25 @@ class Chef end def latest_current_windows_chef_version_query - chef_version_string = if knife_config[:bootstrap_version] - knife_config[:bootstrap_version] - else - Chef::VERSION.split(".").first - end + installer_version_string = nil + if @config[:prerelease] + installer_version_string = "&prerelease=true" + else + 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 the prerelease query string + if chef_version_string.split(".").length > 3 + installer_version_string << "&prerelease=true" + end + end - "&v=#{chef_version_string}" + installer_version_string end def win_wget |