diff options
author | Tim Smith <tsmith@chef.io> | 2021-07-30 18:29:07 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-30 18:29:07 -0700 |
commit | 099defebbc4c1f1c686fde4e4cfc9efc224d9b96 (patch) | |
tree | 8e9d7cd09e428e956ebffe59f1c02fbdcf7914e6 /lib | |
parent | edb5d788d9b4be37e9fad58f643b021f2d4832a2 (diff) | |
parent | 369018972f6022569a954230ab586afe1566ee0f (diff) | |
download | chef-099defebbc4c1f1c686fde4e4cfc9efc224d9b96.tar.gz |
Merge pull request #11882 from chef/lcg/rename-inspec-attributes-to-inputs
Rename inspec attributes to inputs in compliance phase
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/compliance/default_attributes.rb | 4 | ||||
-rw-r--r-- | lib/chef/compliance/runner.rb | 16 |
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/chef/compliance/default_attributes.rb b/lib/chef/compliance/default_attributes.rb index 3a8c8f1ccc..9839cd740b 100644 --- a/lib/chef/compliance/default_attributes.rb +++ b/lib/chef/compliance/default_attributes.rb @@ -47,8 +47,10 @@ class Chef "profiles" => {}, # Extra inputs passed to Chef InSpec to allow finer-grained control over behavior. - # These are mapped to Chef InSpec's inputs, but are named attributes here for legacy reasons. # See Chef Inspec's documentation for more information: https://docs.chef.io/inspec/inputs/ + "inputs" => {}, + + # Legacy alias for inputs "attributes" => {}, # A string path or an array of paths to Chef InSpec waiver files. diff --git a/lib/chef/compliance/runner.rb b/lib/chef/compliance/runner.rb index ec68fe141a..14e776a6b7 100644 --- a/lib/chef/compliance/runner.rb +++ b/lib/chef/compliance/runner.rb @@ -113,8 +113,17 @@ class Chef logger.info "Chef Infra Compliance Phase Complete" end + def inputs_from_attributes + if !node["audit"]["inputs"].empty? + node["audit"]["inputs"].to_h + else + node["audit"]["attributes"].to_h + end + end + def inspec_opts - inputs = node["audit"]["attributes"].to_h + inputs = inputs_from_attributes + if node["audit"]["chef_node_attribute_enabled"] inputs["chef_node"] = node.to_h inputs["chef_node"]["chef_environment"] = node.chef_environment @@ -300,6 +309,11 @@ class Chef raise "CMPL002: Unrecognized Compliance Phase fetcher (node['audit']['fetcher'] = #{fetcher}). Supported fetchers are: #{SUPPORTED_FETCHERS.join(", ")}, or nil. For more information, see the documentation at https://docs.chef.io/chef_compliance_phase#fetch-profiles" end end + + if !node["audit"]["attributes"].empty? && !node["audit"]["inputs"].empty? + raise "CMPL011: both node['audit']['inputs'] and node['audit']['attributes'] are set. The node['audit']['attributes'] setting is deprecated and should not be used." + end + @validation_passed = true end end |