Class: Leeloo::PrivateLocalFileSystemKeystore
Instance Attribute Summary collapse
Attributes inherited from Keystore
#name
Instance Method Summary
collapse
Methods inherited from Keystore
#footprint, #init, #sync
Constructor Details
Returns a new instance of PrivateLocalFileSystemKeystore.
72
73
74
75
76
77
|
# File 'lib/leeloo/keystore.rb', line 72
def initialize name, path
super name
@path = path
File.write("#{@path}/.gpg-id", 'empty') unless File.exist? "#{@path}/.gpg-id"
FileUtils.mkdir_p "#{@path}/secrets"
end
|
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
70
71
72
|
# File 'lib/leeloo/keystore.rb', line 70
def path
@path
end
|
Instance Method Details
#==(keystore) ⇒ Object
96
97
98
|
# File 'lib/leeloo/keystore.rb', line 96
def == keystore
self.name == keystore.name && self.path == keystore.path
end
|
#find_secrets(path) ⇒ Object
87
88
89
90
91
92
93
94
|
# File 'lib/leeloo/keystore.rb', line 87
def find_secrets path
elements = []
Dir.glob("#{path}/**") do |element|
elements << secret_of(element) unless Dir.exist? element
elements << find_secrets(element) if Dir.exist? element
end
return elements.flatten
end
|
109
110
111
112
|
# File 'lib/leeloo/keystore.rb', line 109
def name
secret = secret_from_name name
{ "footprint" => secret., "keystore" => self.name, "secret" => secret.name }
end
|
#keys ⇒ Object
83
84
85
|
# File 'lib/leeloo/keystore.rb', line 83
def keys
[]
end
|
114
115
116
117
118
119
120
|
# File 'lib/leeloo/keystore.rb', line 114
def
secret = secret_from_name ["secret"]
unless secret. == ["footprint"]
raise "footprint is not valid"
end
secret
end
|
#secret_from_name(name) ⇒ Object
105
106
107
|
# File 'lib/leeloo/keystore.rb', line 105
def secret_from_name name
secret_of "#{path}/secrets/#{name}"
end
|
#secret_of(path) ⇒ Object
100
101
102
103
|
# File 'lib/leeloo/keystore.rb', line 100
def secret_of path
name = path.gsub("#{@path}/secrets/", "")
LocalFileSystemSecret.new path, name
end
|
#secrets ⇒ Object
79
80
81
|
# File 'lib/leeloo/keystore.rb', line 79
def secrets
find_secrets "#{@path}/secrets"
end
|