summaryrefslogtreecommitdiff
path: root/lib/chef/knife/core
diff options
context:
space:
mode:
authorMarc A. Paradise <marc.paradise@gmail.com>2019-05-01 11:06:28 -0400
committerMarc A. Paradise <marc.paradise@gmail.com>2019-05-03 17:30:08 -0400
commitf2d590eecc90da7a78593b61437dbac27a480322 (patch)
tree8f5e6dc0d0b1342b87381c6d26fedec05d60f0b0 /lib/chef/knife/core
parentfaeddcb492020f3ead4aa433e93a9903d16ab652 (diff)
downloadchef-f2d590eecc90da7a78593b61437dbac27a480322.tar.gz
`prerelease` -> `channel` in bootstrap contexts
Updates BootstrapContext and WindowsBootstrapContext to expect a 'channel' config value instead of a 'prelease' value. This removes the old behavior of inferring pre-release (current) from the presence of a fourth version number in the version string (eg 1.2.3.pre) - that was specific to gem installs, and gem installs are not used in bootstrap. 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.rb41
-rw-r--r--lib/chef/knife/core/windows_bootstrap_context.rb35
2 files changed, 45 insertions, 31 deletions
diff --git a/lib/chef/knife/core/bootstrap_context.rb b/lib/chef/knife/core/bootstrap_context.rb
index c46a6bc079..5889a77f25 100644
--- a/lib/chef/knife/core/bootstrap_context.rb
+++ b/lib/chef/knife/core/bootstrap_context.rb
@@ -187,26 +187,31 @@ class Chef
end
#
- # 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
+ # Determine that CLI arguments to retrieve the correct version of Chef Infra Client from omnitruck
+ # By default, bootstrap will look for the latest version of the currently-running major release of on stable.
+ #
+ # @return [String] CLI arguments to pass into the chef download helper script
def latest_current_chef_version_string
- 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]
+ # NOTE: Changes here should also be reflected in Knife::Core::BootstrapContext#latest_current_chef_version_string
+ installer_version_string = []
+ use_current_channel = (@config[:channel] == "current")
+ installer_version_string << "-p" if use_current_channel
+ version = if knife_config[:bootstrap_version]
+ knife_config[:bootstrap_version]
+ else
+ # We will take the latest current by default,
+ # if no specific version is given.
+ if use_current_channel
+ # Take the latest stable version from the current major release.
+ # Note that if the current major release is not yet in stable,
+ # you must also specify channel "current".
+ nil
+ else
+ Chef::VERSION.split(".").first
+ end
+ end
- # 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.concat(["-v", version]) unless version.nil?
installer_version_string.join(" ")
end
diff --git a/lib/chef/knife/core/windows_bootstrap_context.rb b/lib/chef/knife/core/windows_bootstrap_context.rb
index c6b8bc4d2b..42d46aa67a 100644
--- a/lib/chef/knife/core/windows_bootstrap_context.rb
+++ b/lib/chef/knife/core/windows_bootstrap_context.rb
@@ -158,24 +158,33 @@ class Chef
start_chef << "chef-client -c c:/chef/client.rb -j c:/chef/first-boot.json#{bootstrap_environment_option}\n"
end
+ #
+ # Provide the query arguments to a URL that will be appeded to the URL in #msi_url(). This is used
+ # to get the latest version of Chef Infra Client via omnitruck
+ # By default, bootstrap will look for the latest version of the currently-running major release of on stable.
+ #
+ # @return [String] query arguments to append to the download request.
def latest_current_windows_chef_version_query
- 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]
+ # NOTE: Changes here should also be reflected in Knife::Core::BootstrapContext#latest_current_chef_version_string
+ use_current_channel = (@config[:channel] == "current")
+ installer_version_string = use_current_channel ? "&prerelease=true" : ""
+
+ chef_version_string = if knife_config[:bootstrap_version]
+ knife_config[:bootstrap_version]
+ else
+ if use_current_channel
+ # We will take the latest current by default,
+ # if no specific version is given.
+ nil
else
+ # Take the latest stable version from the current major release.
+ # Note that if the current major release is not yet in stable,
+ # you must also specify channel "current".
Chef::VERSION.split(".").first
end
+ 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
+ installer_version_string << "&v=#{chef_version_string}" if chef_version_string
installer_version_string
end