class Hiera::Backend::Osxkeychain_backend
Public Class Methods
new()
click to toggle source
# File lib/hiera/backend/osxkeychain_backend.rb, line 93 def initialize @config = Config[:osxkeychain] Hiera.debug("osxkeychain_backend initialized config: #{@config}") end
Public Instance Methods
lookup(key, scope, order_override, resolution_type, *args)
click to toggle source
# File lib/hiera/backend/osxkeychain_backend.rb, line 98 def lookup(key, scope, order_override, resolution_type, *args) # Ignore order_override since it doesn't not have hierarchy. # Ignore scope since no need to interpolate values in anyways. # Use key for account to lookup generic password. result = keychain.lookup(:account => key) # Hiera 2 and later, which has 5th argument, require to throw `:no_such_key` # when no key found, but Hiera 1 requires to return `nil`. if !result && !args.empty? throw(:no_such_key) end case resolution_type when :array if result [result] else [] end when :hash Hiera.warn("Unexpected resolution type.") result else result end end
Private Instance Methods
keychain()
click to toggle source
# File lib/hiera/backend/osxkeychain_backend.rb, line 128 def keychain @keychain ||= Keychain.new(@config[:service] || "hiera") end