Method: Reedb::Vault.scope_vault
- Defined in:
- lib/reedb.rb
.scope_vault(name, path) ⇒ Object
Adds a new vault to the tracking scope of this Reedb daemon. Does not grant access or generate a new token for application interaction. On a new install usually called just before requesting a token
660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 |
# File 'lib/reedb.rb', line 660 def scope_vault(name, path) # Checks if that specific vault was already scoped @@config[:vaults].each do |_, value| if value[:meta].name == "#{name}" && value[:meta].path == "#{path}" DaemonLogger.write("Vault already scoped at #{path}", 'info') raise VaultAlreadyScopedError.new, "Vault #{name} already scoped!" return false end end vault = ReeVault.new("#{name}", "#{path}", :auto) # If it hasn't, proceed here if vault.try? uuid = UUID.new loop do uuid = uuid.generate (break) unless @@config[:vaults].include?(uuid) end # At this point a vault has been confirmed and a UUID generated track_vault(name, path, vault.count, uuid) DaemonLogger.write("Vault successfully scoped at #{path}", 'info') cache_config return true else DaemonLogger.write("Tried to scope empty target at #{path}", 'warn') raise VaultDoesNotExistError.new, "Tried to scope empty target at #{path}" return false end end |