Skip to content

Commit

Permalink
Bug fix with multiple PG installations.
Browse files Browse the repository at this point in the history
Reverse hashmap of pg_version helpers

Style correction modify variable name

Remove commented code

Signed-off-by: Justin Fernbaugh <fernbaughj@gmail.com>

Revert minor bump

Signed-off-by: Justin Fernbaugh <fernbaughj@gmail.com>

Sort array with highest PG version first

Add changelog note

Signed-off-by: Justin Fernbaugh <fernbaughj@gmail.com>

Cleanup sort_by

Move package logic into function

Removed changelog addition
  • Loading branch information
Justin-Fernbaugh authored and ramereth committed Jan 5, 2024
1 parent d220c8b commit cdacedd
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ module Cookbook
module Helpers
include Utils

def installed_postgresql_major_version
def installed_postgresql_package_logic
pgsql_package = node['packages'].filter { |p| p.match?(/^postgresql-?(\d+)?$/) }
pgsql_package = pgsql_package.sort_by { |key, _values| key }.to_h

raise 'Unable to determine installed PostgreSQL version' if nil_or_empty?(pgsql_package)

pgsql_package = pgsql_package.values.first
pgsql_package.values.first
end

def installed_postgresql_major_version
pgsql_package = installed_postgresql_package_logic
pgsql_package_version = pgsql_package.fetch('version').to_i
pgsql_package_source = if pgsql_package.key?('release')
pgsql_package.fetch('release').match?('PGDG') ? :repo : :os
Expand All @@ -42,11 +47,7 @@ def installed_postgresql_major_version
end

def installed_postgresql_package_source
pgsql_package = node['packages'].filter { |p| p.match?(/^postgresql-?(\d+)?$/) }

raise 'Unable to determine installed PostgreSQL version' if nil_or_empty?(pgsql_package)

pgsql_package = pgsql_package.values.first
pgsql_package = installed_postgresql_package_logic
pgsql_package_version = pgsql_package.fetch('version').to_i
pgsql_package_source = if pgsql_package.key?('release')
pgsql_package.fetch('release').match?('PGDG') ? :repo : :os
Expand Down

0 comments on commit cdacedd

Please sign in to comment.