Sha256: a76fbad5d80db2622d1b82419b37c5997bfc780a66eb321a20465072b17a3fca

Contents?: true

Size: 1.33 KB

Versions: 72

Compression:

Stored size: 1.33 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 preserve_key(key)
          return key == 'name'
        end

        def chef_class
          Chef::ApiClient
        end

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

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
chef-11.16.4-x86-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-11.16.4 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-11.16.2-x86-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-11.16.2 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-11.16.0-x86-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-11.16.0 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-11.16.0.rc.0 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-12.0.0.alpha.1-x86-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-12.0.0.alpha.1 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-11.14.6-x86-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-11.14.6 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-11.14.2-x86-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-11.14.2 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-12.0.0.alpha.0-x86-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-12.0.0.alpha.0 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-11.14.0.rc.2-x86-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-11.14.0.rc.2 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-11.14.0.alpha.4 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-11.14.0.alpha.4-x86-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb
chef-11.12.8-x86-mingw32 lib/chef/chef_fs/data_handler/group_data_handler.rb