Sha256: 269417fb7ef06a80e8eccde51fd87e1be37c77f4750bd096ae21cb23e5290a37

Contents?: true

Size: 1.55 KB

Versions: 189

Compression:

Stored size: 1.55 KB

Contents

require_relative "data_handler_base"

class Chef
  module ChefFS
    module DataHandler
      class PolicyDataHandler < DataHandlerBase
        def name_and_revision(name)
          # foo-1.0.0 = foo, 1.0.0
          name = remove_dot_json(name)
          if name =~ /^(.*)-([^-]*)$/
            name, revision_id = $1, $2
          end
          revision_id ||= "0.0.0"
          [ name, revision_id ]
        end

        def normalize(policy, entry)
          # foo-1.0.0 = foo, 1.0.0
          name, revision_id = name_and_revision(entry.name)
          defaults = {
            "name" => name,
            "revision_id" => revision_id,
            "run_list" => [],
            "cookbook_locks" => {},
          }
          normalize_hash(policy, defaults)
        end

        # Verify that the JSON hash for this type has a key that matches its name.
        #
        # @param object_data [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 '#{name}'.")
          end

          if object_data["revision_id"] != revision
            yield("Object revision ID '#{object_data["revision_id"]}' doesn't match entry '#{revision}'.")
          end
        end
      end
    end
  end
end

Version data entries

189 entries across 189 versions & 1 rubygems

Version Path
chef-17.10.163-universal-mingw32 lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-17.10.163 lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-18.5.0-x64-mingw-ucrt lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-18.5.0 lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-18.4.12-x64-mingw-ucrt lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-18.4.12 lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-17.10.122-universal-mingw32 lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-17.10.122 lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-17.10.114-universal-mingw32 lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-17.10.114 lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-18.4.2-x64-mingw-ucrt lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-18.4.2 lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-17.10.95-universal-mingw32 lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-17.10.95 lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-18.3.0-x64-mingw-ucrt lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-18.3.0 lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-17.10.68-universal-mingw32 lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-18.2.7-x64-mingw-ucrt lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-18.2.7 lib/chef/chef_fs/data_handler/policy_data_handler.rb
chef-18.1.29 lib/chef/chef_fs/data_handler/policy_data_handler.rb