Class: Chef::EncryptedAttribute::Config
- Inherits:
-
Object
- Object
- Chef::EncryptedAttribute::Config
- Includes:
- Mixin::ParamsValidate
- Defined in:
- lib/chef/encrypted_attribute/config.rb
Overview
Encrypted attributes configuration options object.
Constant Summary collapse
- OPTIONS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Returns configuration options list.
[ :version, :partial_search, :client_search, :search_max_rows, :node_search, :users, :keys ].freeze
Instance Method Summary collapse
-
#[](key) ⇒ Mixed
Reads a configuration option.
-
#[]=(key, value) ⇒ Mixed
Sets a configuration option.
-
#client_search(arg = nil) ⇒ Array<String>
Reads or sets client search query.
-
#initialize(config = nil) ⇒ Config
constructor
Constructs a Config object.
-
#keys(arg = nil) ⇒ Array<String, OpenSSL::PKey::RSA>
Reads or sets key list.
-
#node_search(arg = nil) ⇒ Array<String>
Reads or sets node search query.
-
#partial_search(arg = nil) ⇒ Boolean
Reads or sets partial search support.
-
#search_max_rows(arg = nil) ⇒ Integer
Set the maximum number of rows to be returned by internal search functions.
-
#update!(config) ⇒ Config
Replaces the current config.
-
#users(arg = nil) ⇒ Array<String>
Reads or sets user list.
-
#version(arg = nil) ⇒ Fixnum
Reads or sets Encrypted Mash protocol version.
Constructor Details
#initialize(config = nil) ⇒ Config
Constructs a Chef::EncryptedAttribute::Config object.
44 45 46 |
# File 'lib/chef/encrypted_attribute/config.rb', line 44 def initialize(config = nil) update!(config) unless config.nil? end |
Instance Method Details
#[](key) ⇒ Mixed
Reads a configuration option.
166 167 168 169 |
# File 'lib/chef/encrypted_attribute/config.rb', line 166 def [](key) key = key.to_sym if key.is_a?(String) send(key) if OPTIONS.include?(key) end |
#[]=(key, value) ⇒ Mixed
Sets a configuration option.
176 177 178 179 |
# File 'lib/chef/encrypted_attribute/config.rb', line 176 def []=(key, value) key = key.to_sym if key.is_a?(String) send(key, value) if OPTIONS.include?(key) end |
#client_search(arg = nil) ⇒ Array<String>
Reads or sets client search query.
This query will return a list of clients that will be able to read the encrypted attribute.
86 87 88 |
# File 'lib/chef/encrypted_attribute/config.rb', line 86 def client_search(arg = nil) set_or_return_search_array(:client_search, arg) end |
#keys(arg = nil) ⇒ Array<String, OpenSSL::PKey::RSA>
Reads or sets key list.
This contains the raw key list that will be able to read the encrypted attribute.
137 138 139 140 141 142 143 |
# File 'lib/chef/encrypted_attribute/config.rb', line 137 def keys(arg = nil) set_or_return( :keys, arg, kind_of: Array, default: [], callbacks: config_valid_keys_array_callbacks ) end |
#node_search(arg = nil) ⇒ Array<String>
Reads or sets node search query.
This query will return a list of nodes that will be able to read the encrypted attribute.
111 112 113 |
# File 'lib/chef/encrypted_attribute/config.rb', line 111 def node_search(arg = nil) set_or_return_search_array(:node_search, arg) end |
#partial_search(arg = nil) ⇒ Boolean
Reads or sets partial search support.
Set it to false
to disable partial search. Defaults to true
.
71 72 73 74 75 |
# File 'lib/chef/encrypted_attribute/config.rb', line 71 def partial_search(arg = nil) set_or_return( :partial_search, arg, kind_of: [TrueClass, FalseClass], default: true ) end |
#search_max_rows(arg = nil) ⇒ Integer
Set the maximum number of rows to be returned by internal search functions.
You must set this value to your maximum number of nodes in your Chef
Server. Defaults to 1000
.
98 99 100 101 102 |
# File 'lib/chef/encrypted_attribute/config.rb', line 98 def search_max_rows(arg = nil) set_or_return( :search_max_rows, arg, kind_of: Integer, default: 1000 ) end |
#update!(config) ⇒ Config
Replaces the current config.
When setting using a Chef::EncryptedAttribute::Config class, all the configuration options will be replaced.
When setting using a Hash, only the provided keys will be replaced.
154 155 156 157 158 159 160 |
# File 'lib/chef/encrypted_attribute/config.rb', line 154 def update!(config) if config.is_a?(self.class) update_from_config!(config) elsif config.is_a?(Hash) update_from_hash!(config) end end |
#users(arg = nil) ⇒ Array<String>
Reads or sets user list.
This contains the user list that will be able to read the encrypted attribute.
122 123 124 125 126 127 128 |
# File 'lib/chef/encrypted_attribute/config.rb', line 122 def users(arg = nil) set_or_return( :users, arg, kind_of: [String, Array], default: [], callbacks: config_users_arg_callbacks ) end |
#version(arg = nil) ⇒ Fixnum
Reads or sets Encrypted Mash protocol version.
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/chef/encrypted_attribute/config.rb', line 52 def version(arg = nil) unless arg.nil? || !arg.is_a?(String) begin arg = Integer(arg) rescue ArgumentError arg end end set_or_return(:version, arg, kind_of: [Fixnum, String], default: 1) end |