lib/legion/crypt/vault.rb in legion-crypt-0.2.3 vs lib/legion/crypt/vault.rb in legion-crypt-0.3.0

- old
+ new

@@ -34,44 +34,43 @@ add_session(path: lease.lease_id) if lease.respond_to? :lease_id lease.data end def get(path) - result = ::Vault.kv('legion').read(path) + result = ::Vault.kv(settings[:vault][:kv_path]).read(path) return nil if result.nil? result.data end - def write(path, key, value) - hash = {} - hash[key.to_sym] = value - ::Vault.kv('legion').write(path, **hash) + def write(path, **hash) + ::Vault.kv(settings[:vault][:kv_path]).write(path, **hash) end def exist?(path) - !::Vault.kv('legion').read_metadata(path).nil? + !::Vault.kv(settings[:vault][:kv_path]).read_metadata(path).nil? end def add_session(path:) @sessions.push(path) end def close_sessions - Legion::Logging.info 'Closing all Legion::Crypt vault sessions' return if @sessions.nil? + Legion::Logging.info 'Closing all Legion::Crypt vault sessions' + @sessions.each do |session| close_session(session: session) end end def shutdown_renewer return unless Legion::Settings[:crypt][:vault][:connected] return if @renewer.nil? - Legion::Logging.debug 'Shutdown down Legion::Crypt::Vault::Renewer' + Legion::Logging.debug 'Shutting down Legion::Crypt::Vault::Renewer' @renewer.cancel end def close_session(session:) ::Vault.sys.revoke(session) @@ -83,9 +82,13 @@ def renew_sessions(**_opts) @sessions.each do |session| renew_session(session: session) end + end + + def vault_exists?(name) + ::Vault.sys.mounts.key?(name.to_sym) end end end end