Class: LeapCli::Config::Secrets
- Defined in:
- lib/leap_cli/config/secrets.rb
Instance Attribute Summary collapse
-
#node_list ⇒ Object
readonly
Returns the value of attribute node_list.
Attributes inherited from Object
Instance Method Summary collapse
-
#dump_json(only_discovered_keys = false) ⇒ Object
if only_discovered_keys is true, then we will only export those secrets that have been discovered and the prior ones will be cleaned out.
-
#initialize(manager = nil) ⇒ Secrets
constructor
A new instance of Secrets.
- #set(key, value, environment = nil) ⇒ Object
Methods inherited from Object
#[], #deep_merge!, #default, #dump_yaml, #evaluate, #get, #get!, #inherit_from!, #method_missing, #pick
Methods included from Macros
#assert, #authorized_keys, #base32_secret, #file, #file_path, #fingerprint, #haproxy_servers, #hex_secret, #hostnames, #hosts_file, #nodes, #nodes_like_me, #provider, #rand_range, #secret, #stunnel_client, #stunnel_port, #stunnel_server, #try, #try_file
Methods inherited from Hash
#deep_merge, #deep_merge!, #pick
Constructor Details
#initialize(manager = nil) ⇒ Secrets
Returns a new instance of Secrets.
11 12 13 14 |
# File 'lib/leap_cli/config/secrets.rb', line 11 def initialize(manager=nil) super(manager) @discovered_keys = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class LeapCli::Config::Object
Instance Attribute Details
#node_list ⇒ Object (readonly)
Returns the value of attribute node_list.
9 10 11 |
# File 'lib/leap_cli/config/secrets.rb', line 9 def node_list @node_list end |
Instance Method Details
#dump_json(only_discovered_keys = false) ⇒ Object
if only_discovered_keys is true, then we will only export those secrets that have been discovered and the prior ones will be cleaned out.
this should only be triggered when all nodes have been processed, otherwise secrets that are actually in use will get mistakenly removed.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/leap_cli/config/secrets.rb', line 32 def dump_json(only_discovered_keys=false) if only_discovered_keys self.each_key do |environment| self[environment].each_key do |key| unless @discovered_keys[environment] && @discovered_keys[environment][key] self[environment].delete(key) end end if self[environment].empty? self.delete(environment) end end end super() end |
#set(key, value, environment = nil) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/leap_cli/config/secrets.rb', line 16 def set(key, value, environment=nil) environment ||= 'default' key = key.to_s @discovered_keys[environment] ||= {} @discovered_keys[environment][key] = true self[environment] ||= {} self[environment][key] ||= value end |