Module: Cumulus::IAM::Loader
- Includes:
- Common::BaseLoader
- Defined in:
- lib/iam/loader/Loader.rb
Overview
Public: A module that handles loading all the json configuration files and creating objects from them.
Constant Summary collapse
- @@group_loader =
Proc.new { |name, json| GroupConfig.new(name, json) }
- @@groups_dir =
Configuration.instance.iam.groups_directory
- @@role_loader =
Proc.new { |name, json| RoleConfig.new(name, json) }
- @@roles_dir =
Configuration.instance.iam.roles_directory
- @@user_loader =
Proc.new { |name, json| UserConfig.new(name, json) }
- @@users_dir =
Configuration.instance.iam.users_directory
- @@static_policy_dir =
Configuration.instance.iam.static_policy_directory
- @@template_dir =
Configuration.instance.iam.template_policy_directory
- @@policy_loader =
Proc.new do |name, json| if json.is_a?(Array) json.map do |s| StatementConfig.new(s) end else StatementConfig.new(json) end end
Class Method Summary collapse
-
.group(file) ⇒ Object
Public: Load a group defined in configuration.
-
.groups ⇒ Object
Public: Load all the groups defined in configuration.
-
.policy_document(file) ⇒ Object
Public: Load the JSON string that is a role’s policy document from a file.
-
.role(file) ⇒ Object
Public: Load a role defined in configuration.
-
.roles ⇒ Object
Public: Load all the roles defined in configuration.
-
.static_policy(file) ⇒ Object
Public: Load in a static policy as StatementConfig object.
-
.template_policy(file, variables) ⇒ Object
Public: Load in a template policy, apply variables, and create a StatementConfig object from the result.
-
.user(file) ⇒ Object
Public: Load a user defined in configuration.
-
.users ⇒ Object
Public: Load all the users defined in configuration.
Methods included from Common::BaseLoader
load_file, resource, resources, template
Class Method Details
.group(file) ⇒ Object
Public: Load a group defined in configuration
file - the file the group definition is found in
Returns the GroupConfig object defined by the file
81 82 83 |
# File 'lib/iam/loader/Loader.rb', line 81 def Loader.group(file) Common::BaseLoader.resource(file, @@groups_dir, &@@group_loader) end |
.groups ⇒ Object
Public: Load all the groups defined in configuration.
Returns an Array of GroupConfig objects defined by the groups configuration files.
72 73 74 |
# File 'lib/iam/loader/Loader.rb', line 72 def Loader.groups Common::BaseLoader.resources(@@groups_dir, &@@group_loader) end |
.policy_document(file) ⇒ Object
Public: Load the JSON string that is a role’s policy document from a file.
file - the String name of the policy document file to load
Returns the String contents of the policy document file
110 111 112 113 |
# File 'lib/iam/loader/Loader.rb', line 110 def Loader.policy_document(file) policy_dir = Configuration.instance.iam.policy_document_directory Common::BaseLoader.load_file(file, policy_dir) end |
.role(file) ⇒ Object
Public: Load a role defined in configuration
file - the name of the role to load
Returns a RoleConfig object defined by the role configuration files.
48 49 50 |
# File 'lib/iam/loader/Loader.rb', line 48 def Loader.role(file) Common::BaseLoader.resource(file, @@roles_dir, &@@role_loader) end |
.roles ⇒ Object
Public: Load all the roles defined in configuration.
Returns an Array of RoleConfig objects defined by the roles configuration files.
39 40 41 |
# File 'lib/iam/loader/Loader.rb', line 39 def Loader.roles Common::BaseLoader.resources(@@roles_dir, &@@role_loader) end |
.static_policy(file) ⇒ Object
Public: Load in a static policy as StatementConfig object
file - the String name of the static policy file to load
Returns a StatementConfig object corresponding to the static policy
90 91 92 |
# File 'lib/iam/loader/Loader.rb', line 90 def Loader.static_policy(file) Common::BaseLoader.resource(file, @@static_policy_dir, &@@policy_loader) end |
.template_policy(file, variables) ⇒ Object
Public: Load in a template policy, apply variables, and create a StatementConfig object from the result
file - the String name of the template policy file to load variables - a Hash of variables to apply to the template
Returns a StatementConfig object corresponding to the applied template policy
101 102 103 |
# File 'lib/iam/loader/Loader.rb', line 101 def Loader.template_policy(file, variables) Common::BaseLoader.template(file, @@template_dir, variables, &@@policy_loader) end |
.user(file) ⇒ Object
Public: Load a user defined in configuration
file - the file the user definition is found in
Returns the UserConfig object defined by the file.
64 65 66 |
# File 'lib/iam/loader/Loader.rb', line 64 def Loader.user(file) Common::BaseLoader.resource(file, @@users_dir, &@@user_loader) end |
.users ⇒ Object
Public: Load all the users defined in configuration.
Returns an Array of UserConfig objects defined in user configuration files.
55 56 57 |
# File 'lib/iam/loader/Loader.rb', line 55 def Loader.users Common::BaseLoader.resources(@@users_dir, &@@user_loader) end |