Class: Chef::ChefFS::FileSystem::ChefServer::AclsDir

Inherits:
BaseFSDir show all
Defined in:
lib/chef/chef_fs/file_system/chef_server/acls_dir.rb

Constant Summary collapse

ENTITY_TYPES =

we don’t read sandboxes, so we don’t read their acls

%w{clients containers cookbook_artifacts cookbooks data_bags environments groups nodes policies policy_groups roles}.freeze

Instance Attribute Summary

Attributes inherited from BaseFSObject

#name, #parent, #path

Instance Method Summary collapse

Methods inherited from BaseFSDir

#dir?, #empty?, #initialize

Methods inherited from BaseFSObject

#chef_object, #child, #compare_to, #create_child, #delete, #dir?, #exists?, #initialize, #path_for_printing, #read, #root, #write

Constructor Details

This class inherits a constructor from Chef::ChefFS::FileSystem::BaseFSDir

Instance Method Details

#api_pathObject



37
38
39
# File 'lib/chef/chef_fs/file_system/chef_server/acls_dir.rb', line 37

def api_path
  parent.api_path
end

#can_have_child?(name, is_dir) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/chef/chef_fs/file_system/chef_server/acls_dir.rb', line 45

def can_have_child?(name, is_dir)
  is_dir ? ENTITY_TYPES.include?(name) : name == "organization.json"
end

#childrenObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/chef/chef_fs/file_system/chef_server/acls_dir.rb', line 49

def children
  if @children.nil?
    @children = ENTITY_TYPES.map do |entity_type|
      # All three of these can be versioned (NAME-VERSION), but only have
      # one ACL that covers them all (NAME.json).
      case entity_type
      when "cookbooks", "cookbook_artifacts"
        CookbooksAclDir.new(entity_type, self)
      when "policies"
        PoliciesAclDir.new(entity_type, self)
      else
        AclDir.new(entity_type, self)
      end
    end
    @children << AclEntry.new("organization.json", self, true) # the org acl is retrieved as GET /organizations/ORGNAME/ANYTHING/_acl
  end
  @children
end

#data_handlerObject



33
34
35
# File 'lib/chef/chef_fs/file_system/chef_server/acls_dir.rb', line 33

def data_handler
  @data_handler ||= Chef::ChefFS::DataHandler::AclDataHandler.new
end

#make_child_entry(name) ⇒ Object



41
42
43
# File 'lib/chef/chef_fs/file_system/chef_server/acls_dir.rb', line 41

def make_child_entry(name)
  children.find { |child| child.name == name }
end

#restObject



68
69
70
# File 'lib/chef/chef_fs/file_system/chef_server/acls_dir.rb', line 68

def rest
  parent.rest
end