add more docs

This commit is contained in:
Aleksandr Lossenko
2024-11-03 15:34:59 +01:00
parent d6c4411e97
commit 4d09f3c242

View File

@@ -1,5 +1,9 @@
require "open3" require "open3"
##
# Enpass is different from most password managers, in a way that it's offline. A path to a vault is treated as account.
#
# Pass it like so: `kamal secrets fetch --adapter enpass --account /Users/YOUR_USERNAME/Library/Containers/in.sinew.Enpass-Desktop/Data/Documents/Vaults/primary --from MY_PROD_SERVER`
class Kamal::Secrets::Adapters::Enpass < Kamal::Secrets::Adapters::Base class Kamal::Secrets::Adapters::Enpass < Kamal::Secrets::Adapters::Base
private private
def login(account) def login(account)
@@ -28,7 +32,7 @@ class Kamal::Secrets::Adapters::Enpass < Kamal::Secrets::Adapters::Base
def fetch_secret_titles(secrets) def fetch_secret_titles(secrets)
secrets.reduce(Set.new) do |acc, secret| secrets.reduce(Set.new) do |acc, secret|
# Use rpartition to split the string at the last '/' # Sometimes secrets contain a '/', sometimes not
key, separator, value = secret.rpartition("/") key, separator, value = secret.rpartition("/")
if key.empty? if key.empty?
acc << value acc << value
@@ -44,7 +48,6 @@ class Kamal::Secrets::Adapters::Enpass < Kamal::Secrets::Adapters::Base
label = line[/label:\s*(.*?)\s{2}/, 1] label = line[/label:\s*(.*?)\s{2}/, 1]
password = line[/password:\s*([^"]+)/, 1] password = line[/password:\s*([^"]+)/, 1]
# If title and label are not empty and password is defined, add to the hash
if title && !password.to_s.empty? if title && !password.to_s.empty?
key = label.nil? || label.empty? ? title : "#{title}/#{label}" key = label.nil? || label.empty? ? title : "#{title}/#{label}"
if secrets.include?(title) || secrets.include?(key) if secrets.include?(title) || secrets.include?(key)