Class: Cabal::API::ClusterService
- Inherits:
-
Object
- Object
- Cabal::API::ClusterService
- Defined in:
- lib/cabal/api/cluster_service.rb
Instance Attribute Summary collapse
-
#private_keys ⇒ Object
Returns the value of attribute private_keys.
-
#public_keys ⇒ Object
Returns the value of attribute public_keys.
Instance Method Summary collapse
- #create(name) ⇒ Object
-
#initialize(public_warehouse: STORAGE[:public], private_warehouse: STORAGE[:private]) ⇒ ClusterService
constructor
A new instance of ClusterService.
- #names ⇒ Object
- #private_key(name) ⇒ Object
- #public_key(name) ⇒ Object
Constructor Details
#initialize(public_warehouse: STORAGE[:public], private_warehouse: STORAGE[:private]) ⇒ ClusterService
Returns a new instance of ClusterService.
11 12 13 14 15 |
# File 'lib/cabal/api/cluster_service.rb', line 11 def initialize(public_warehouse: STORAGE[:public], private_warehouse: STORAGE[:private]) @public_keys = Sekrat.manager(warehouse: public_warehouse) @private_keys = Sekrat.manager(warehouse: private_warehouse, crypter: Sekrat::Crypter::Aes) end |
Instance Attribute Details
#private_keys ⇒ Object
Returns the value of attribute private_keys.
9 10 11 |
# File 'lib/cabal/api/cluster_service.rb', line 9 def private_keys @private_keys end |
#public_keys ⇒ Object
Returns the value of attribute public_keys.
9 10 11 |
# File 'lib/cabal/api/cluster_service.rb', line 9 def public_keys @public_keys end |
Instance Method Details
#create(name) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/cabal/api/cluster_service.rb', line 17 def create(name) sshkey = SSHKey.generate( type: 'RSA', bits: 2048, comment: "#{name}-cabal" ) write_public_key(name, sshkey) && write_private_key(name, sshkey) end |
#names ⇒ Object
27 28 29 |
# File 'lib/cabal/api/cluster_service.rb', line 27 def names public_keys.ids end |
#private_key(name) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/cabal/api/cluster_service.rb', line 39 def private_key(name) begin private_keys.get(name, public_key(name)) rescue nil end end |
#public_key(name) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/cabal/api/cluster_service.rb', line 31 def public_key(name) begin public_keys.get(name, name) rescue nil end end |