diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-03-04 11:11:40 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-03-04 11:11:40 -0800 |
commit | 4fd88f1f3c7d847712e61abab2bac6cb4a987265 (patch) | |
tree | dfb881adfed537b6f6c9084f7a61779416605e1e /lib/chef/chef_fs | |
parent | f17fc92d3b8400cc91bfd384c5bf39fd40bdf5b1 (diff) | |
download | chef-4fd88f1f3c7d847712e61abab2bac6cb4a987265.tar.gz |
add some @yield docs
added some FIXMEs because trying to sort out types for random undocumented code was making me completely aggro
Diffstat (limited to 'lib/chef/chef_fs')
6 files changed, 37 insertions, 5 deletions
diff --git a/lib/chef/chef_fs/data_handler/container_data_handler.rb b/lib/chef/chef_fs/data_handler/container_data_handler.rb index 27bb9dc736..04973b5135 100644 --- a/lib/chef/chef_fs/data_handler/container_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/container_data_handler.rb @@ -15,10 +15,16 @@ class Chef return key == "containername" end + # Verify that the JSON hash for this type has a key that matches its name. + # + # @param object [Object] JSON hash of the object + # @param entry [Chef::ChefFS::FileSystem::BaseFSObject] filesystem object we are verifying + # @yield [s] callback to handle errors + # @yieldparam [s<string>] error message def verify_integrity(object, entry) base_name = remove_dot_json(entry.name) if object["containername"] != base_name - yield("Name in #{entry.path_for_printing} must be '#{base_name}' (is '#{object['name']}')") + yield("Name in #{entry.path_for_printing} must be '#{base_name}' (is '#{object['containername']}')") end end diff --git a/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb b/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb index 89087e159f..c6b6449d52 100644 --- a/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/data_bag_item_data_handler.rb @@ -42,6 +42,12 @@ class Chef Chef::DataBagItem end + # Verify that the JSON hash for this type has a key that matches its name. + # + # @param object [Object] JSON hash of the object + # @param entry [Chef::ChefFS::FileSystem::BaseFSObject] filesystem object we are verifying + # @yield [s] callback to handle errors + # @yieldparam [s<string>] error message def verify_integrity(object, entry) base_name = remove_dot_json(entry.name) if object["raw_data"]["id"] != base_name diff --git a/lib/chef/chef_fs/data_handler/data_handler_base.rb b/lib/chef/chef_fs/data_handler/data_handler_base.rb index f487218f31..b30ae9c708 100644 --- a/lib/chef/chef_fs/data_handler/data_handler_base.rb +++ b/lib/chef/chef_fs/data_handler/data_handler_base.rb @@ -185,10 +185,12 @@ class Chef result end - # # Verify that the JSON hash for this type has a key that matches its name. - # Calls the on_error block with the error, if there is one. # + # @param object [Object] JSON hash of the object + # @param entry [Chef::ChefFS::FileSystem::BaseFSObject] filesystem object we are verifying + # @yield [s] callback to handle errors + # @yieldparam [s<string>] error message def verify_integrity(object, entry) base_name = remove_dot_json(entry.name) if object["name"] != base_name diff --git a/lib/chef/chef_fs/data_handler/organization_data_handler.rb b/lib/chef/chef_fs/data_handler/organization_data_handler.rb index 4afde75d40..0facd5d55d 100644 --- a/lib/chef/chef_fs/data_handler/organization_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/organization_data_handler.rb @@ -19,6 +19,12 @@ class Chef return key == "name" end + # Verify that the JSON hash for this type has a key that matches its name. + # + # @param object [Object] JSON hash of the object + # @param entry [Chef::ChefFS::FileSystem::BaseFSObject] filesystem object we are verifying + # @yield [s] callback to handle errors + # @yieldparam [s<string>] error message def verify_integrity(object, entry) if entry.org != object["name"] yield("Name must be '#{entry.org}' (is '#{object['name']}')") diff --git a/lib/chef/chef_fs/data_handler/policy_data_handler.rb b/lib/chef/chef_fs/data_handler/policy_data_handler.rb index f88b41401f..fa7bbe9101 100644 --- a/lib/chef/chef_fs/data_handler/policy_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/policy_data_handler.rb @@ -26,14 +26,20 @@ class Chef normalize_hash(policy, defaults) end + # Verify that the JSON hash for this type has a key that matches its name. + # + # @param object [Object] JSON hash of the object + # @param entry [Chef::ChefFS::FileSystem::BaseFSObject] filesystem object we are verifying + # @yield [s] callback to handle errors + # @yieldparam [s<string>] error message def verify_integrity(object_data, entry) name, revision = name_and_revision(entry.name) if object_data["name"] != name - yield("Object name '#{object_data['name']}' doesn't match entry '#{entry.name}'.") + yield("Object name '#{object_data['name']}' doesn't match entry '#{name}'.") end if object_data["revision_id"] != revision - yield("Object revision ID '#{object_data['revision']}' doesn't match entry '#{entry.name}'.") + yield("Object revision ID '#{object_data['revision_id']}' doesn't match entry '#{revision}'.") end end end diff --git a/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb b/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb index e20676a791..f7aa92373c 100644 --- a/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/policy_group_data_handler.rb @@ -15,6 +15,12 @@ class Chef result end + # Verify that the JSON hash for this type has a key that matches its name. + # + # @param object [Object] JSON hash of the object + # @param entry [Chef::ChefFS::FileSystem::BaseFSObject] filesystem object we are verifying + # @yield [s] callback to handle errors + # @yieldparam [s<string>] error message def verify_integrity(object_data, entry) if object_data["policies"].empty? yield("Policy group #{object_data["name"]} does not have any policies in it.") |