From 35fde7009976d30d3783266b51828a6afe5f712c Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Thu, 16 Apr 2020 20:50:56 -0700 Subject: Fix platform_version Chef::VersionString API The consumption of ohai attributes by the ohai segment plugin code was breaking this feature. Signed-off-by: Lamont Granquist --- lib/chef/node.rb | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/chef/node.rb b/lib/chef/node.rb index 8a4949000e..e757e93d77 100644 --- a/lib/chef/node.rb +++ b/lib/chef/node.rb @@ -351,14 +351,30 @@ class Chef run_list.detect { |r| r == item } ? true : false end - # Consume data from ohai and Attributes provided as JSON on the command line. + # Handles both the consumption of ohai data and possibly JSON attributes from the CLI + # + # @api private def consume_external_attrs(ohai_data, json_cli_attrs) # FIXME(log): should be trace logger.debug("Extracting run list from JSON attributes provided on command line") consume_attributes(json_cli_attrs) self.automatic_attrs = ohai_data + fix_automatic_attributes + end + + # This is for ohai plugins to consume ohai data and have it merged, it should probably be renamed + # + # @api private + def consume_ohai_data(ohai_data) + self.automatic_attrs = Chef::Mixin::DeepMerge.merge(automatic_attrs, ohai_data) + fix_automatic_attributes + end + # Always ensure that certain automatic attributes are populated and constructed correctly + # + # @api private + def fix_automatic_attributes platform, version = Chef::Platform.find_platform_and_version(self) # FIXME(log): should be trace logger.debug("Platform is #{platform} version #{version}") @@ -369,10 +385,6 @@ class Chef automatic[:chef_environment] = chef_environment end - def consume_ohai_data(ohai_data) - self.automatic_attrs = Chef::Mixin::DeepMerge.merge(automatic_attrs, ohai_data) - end - # Consumes the combined run_list and other attributes in +attrs+ def consume_attributes(attrs) normal_attrs_to_merge = consume_run_list(attrs) -- cgit v1.2.1