Sha256: 85280f5f85ed6437793cc134ad93050dae692b371075e274d7f333fbf50e544b

Contents?: true

Size: 1.48 KB

Versions: 27

Compression:

Stored size: 1.48 KB

Contents

require "chef/chef_fs/data_handler/data_handler_base"
require "chef/api_client"

class Chef
  module ChefFS
    module DataHandler
      class GroupDataHandler < DataHandlerBase
        def normalize(group, entry)
          defaults = {
            "name" => remove_dot_json(entry.name),
            "groupname" => remove_dot_json(entry.name),
            "users" => [],
            "clients" => [],
            "groups" => [],
          }
          if entry.org
            defaults["orgname"] = entry.org
          end
          result = normalize_hash(group, defaults)
          if result["actors"] && result["actors"].sort.uniq == (result["users"] + result["clients"]).sort.uniq
            result.delete("actors")
          end
          result
        end

        def normalize_for_put(group, entry)
          result = super(group, entry)
          result["actors"] = {
            "users" => result["users"],
            "clients" => result["clients"],
            "groups" => result["groups"],
          }
          result.delete("users")
          result.delete("clients")
          result.delete("groups")
          result
        end

        def normalize_for_post(group, entry)
          normalize_for_put(group, entry)
        end

        def preserve_key?(key)
          key == "name"
        end

        def chef_class
          Chef::ApiClient
        end

        # There is no Ruby API for Chef::ApiClient
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
chef-14.13.11-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-14.12.9-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-14.12.3-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-13.12.14-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-14.11.21-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-14.10.9-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-14.9.13-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-14.8.12-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-14.7.17-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-13.12.3-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-14.6.47-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-13.11.3-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-14.5.33-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-13.10.4-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-14.3.37-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-13.10.0-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-13.9.4-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-14.2.0-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-14.1.12-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-14.1.1-universal-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb