Skip to content

Commit 3e04518

Browse files
committed
Fix default password_encryption in postgresql_password based on params
1 parent 6db5691 commit 3e04518

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

REFERENCE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4429,6 +4429,8 @@ Data type: `Optional[Optional[Postgresql::Pg_password_encryption]]`
44294429

44304430
Set type for password hash
44314431

4432+
Default value comes from `postgresql::params::password_encryption` and changes based on the `postgresql::globals::version`.
4433+
44324434
##### `salt`
44334435

44344436
Data type: `Optional[Optional[Variant[String[1], Integer]]]`

lib/puppet/functions/postgresql/postgresql_password.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# If the Postgresql-Passwordhash should be of Datatype Sensitive[String]
1414
# @param hash
1515
# Set type for password hash
16+
#
17+
# Default value comes from `postgresql::params::password_encryption` and changes based on the `postgresql::globals::version`.
1618
# @param salt
1719
# Use a specific salt value for scram-sha-256, default is username
1820
#
@@ -27,7 +29,8 @@
2729
return_type 'Variant[String, Sensitive[String]]'
2830
end
2931

30-
def default_impl(username, password, sensitive = false, hash = 'md5', salt = nil)
32+
def default_impl(username, password, sensitive = false, hash = nil, salt = nil)
33+
hash = call_function(:'postgresql::default', 'password_encryption') if hash.nil?
3134
password = password.unwrap if password.respond_to?(:unwrap)
3235
if password.is_a?(String) && password.match?(%r{^(md5[0-9a-f]{32}$|SCRAM-SHA-256\$)})
3336
return Puppet::Pops::Types::PSensitiveType::Sensitive.new(password) if sensitive

spec/functions/postgresql_password_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
require 'spec_helper'
44

55
describe 'postgresql_password' do
6+
include_examples 'Ubuntu 18.04'
7+
68
it_behaves_like 'postgresql_password function'
79
end

spec/functions/postgresql_postgresql_password_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
require 'spec_helper'
44

55
describe 'postgresql::postgresql_password' do
6+
include_examples 'Ubuntu 18.04'
7+
68
it_behaves_like 'postgresql_password function'
79
end

0 commit comments

Comments
 (0)