Class: Chef::EncryptedAttribute::RemoteClients
- Inherits:
-
Object
- Object
- Chef::EncryptedAttribute::RemoteClients
- Extended by:
- SearchHelper
- Defined in:
- lib/chef/encrypted_attribute/remote_clients.rb
Overview
Search remote Chef Clients public keys.
Class Method Summary collapse
-
.cache ⇒ CacheLru
Remote clients search results cache.
-
.get_public_key(name) ⇒ String
Gets remote client public key.
-
.search_public_keys(search = '*:*', rows = 1000, partial_search = true) ⇒ Array<String>
Searches for chef client public keys.
Methods included from SearchHelper
assert_normal_search_response, assert_partial_search_response, assert_search_keys, catch_search_exceptions, empty_search?, escape, escape_query, filter_normal_search_response, filter_partial_search_response, generate_partial_search_keys, normal_search, parse_normal_search_response, parse_normal_search_row_attribute, parse_partial_search_response, partial_search, query, search, search_by_name, valid_search_keys?, valid_search_keys_key?, valid_search_keys_value?
Class Method Details
.cache ⇒ CacheLru
Remote clients search results cache.
You can disable it setting it's size to zero:
Chef::EncryptedAttribute::RemoteClients.cache.max_size(0)
41 42 43 |
# File 'lib/chef/encrypted_attribute/remote_clients.rb', line 41 def self.cache @@cache ||= Chef::EncryptedAttribute::CacheLru.new end |
.get_public_key(name) ⇒ String
Gets remote client public key.
51 52 53 54 55 56 |
# File 'lib/chef/encrypted_attribute/remote_clients.rb', line 51 def self.get_public_key(name) Chef::ApiClient.load(name).public_key rescue Net::HTTPServerException => e raise e unless e.response.code == '404' raise ClientNotFound, "Chef Client not found: #{name.inspect}." end |
.search_public_keys(search = '*:*', rows = 1000, partial_search = true) ⇒ Array<String>
Searches for chef client public keys.
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/chef/encrypted_attribute/remote_clients.rb', line 68 def self.search_public_keys( search = '*:*', rows = 1000, partial_search = true ) escaped_query = escape_query(search) return cache[escaped_query] if cache.key?(escaped_query) cache[escaped_query] = search( :client, search, { 'public_key' => %w(public_key) }, rows, partial_search ).map { |client| client['public_key'] }.compact end |