summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2020-04-16 20:50:56 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2020-04-16 20:50:56 -0700
commit35fde7009976d30d3783266b51828a6afe5f712c (patch)
treefd204fa4837af8c8ddcfd0e8afffc3c8ef32071a
parentb521627e9d706a016e232d335cab0ddbb8b3e6ba (diff)
downloadchef-35fde7009976d30d3783266b51828a6afe5f712c.tar.gz
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 <lamont@scriptkiddie.org>
-rw-r--r--lib/chef/node.rb22
1 files 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)