lib/skalera/services/credentials.rb in skalera-services-0.2.1 vs lib/skalera/services/credentials.rb in skalera-services-0.2.2
- old
+ new
@@ -17,13 +17,16 @@
next
end
yield host, username, password if block_given?
[host, username, password]
end.compact # in case there is an error
+ rescue Diplomat::KeyNotFound
+ STDERR.puts "ERROR: key not found: credentials/#{service_name}"
end
def self.extract(creds, key, field)
result = {}
+ # TODO: handle errors when decoding the contents
creds.select { |c| c[:key].match(%r{/#{field}$}) }.each do |hash|
host = hash[:key].match(%r{#{key}/(.+)/#{field}})[1]
result[host] = hash[:value]
end
result