lib/hiera/backend/mysql2_backend.rb in hiera-mysql-backend-0.0.4 vs lib/hiera/backend/mysql2_backend.rb in hiera-mysql-backend-0.0.5

- old
+ new

@@ -18,11 +18,11 @@ def lookup(key, scope, order_override, resolution_type) # default answer is set to nil otherwise the lookup ends up returning # an Array of nils and causing a Puppet::Parser::AST::Resource failed with error ArgumentError # for any other lookup because their default value is overwriten by [nil,nil,nil,nil] # so hiera('myvalue', 'test1') returns [nil,nil,nil,nil] - results = nil + results = nil Hiera.debug("looking up #{key} in MySQL2 Backend") Hiera.debug("resolution type is #{resolution_type}") Backend.datasources(scope, order_override) do |source| @@ -35,27 +35,29 @@ end mysql_host = data.fetch(:dbconfig, {}).fetch(:host, nil) || Config[:mysql2][:host] mysql_user = data.fetch(:dbconfig, {}).fetch(:user, nil) || Config[:mysql2][:user] mysql_pass = data.fetch(:dbconfig, {}).fetch(:pass, nil) || Config[:mysql2][:pass] + mysql_port = data.fetch(:dbconfig, {}).fetch(:port, nil) || Config[:mysql2][:port] mysql_database = data.fetch(:dbconfig, {}).fetch(:database, nil) || Config[:mysql2][:database] connection_hash = { - :host => mysql_host, - :username => mysql_user, - :password => mysql_pass, + :host => mysql_host, + :username => mysql_user, + :password => mysql_pass, :database => mysql_database, + :port => mysql_port, :reconnect => true} - Hiera.debug("data #{data.inspect}") - next if data.empty? - next unless data.include?(key) + Hiera.debug("data #{data.inspect}") + next if data.empty? + next unless data.include?(key) - Hiera.debug("Found #{key} in #{source}") + Hiera.debug("Found #{key} in #{source}") - new_answer = Backend.parse_answer(data[key], scope) - results = query(connection_hash, new_answer) + new_answer = Backend.parse_answer(data[key], scope) + results = query(connection_hash, new_answer) end return results end