Skip to content

Commit

Permalink
port parameter: log warning when its a string
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Aug 28, 2023
1 parent 56bc346 commit e5e6309
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 4 deletions.
3 changes: 3 additions & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@
#Deprecated
Optional[String[1]] $version = undef,
) inherits postgresql::params {
if $port =~ String {
warning('Passing a string to the port parameter is deprecated. Stdlib::Port will be the enforced datatype in the next major release')
}
if $version != undef {
warning('Passing "version" to postgresql::server is deprecated; please use postgresql::globals instead.')
$_version = $version
Expand Down
3 changes: 3 additions & 0 deletions manifests/server/default_privileges.pp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
Variant[String[1], Stdlib::Absolutepath] $psql_path = $postgresql::server::psql_path,
Optional[String] $target_role = undef,
) {
if $port =~ String {
warning('Passing a string to the port parameter is deprecated. Stdlib::Port will be the enforced datatype in the next major release')
}
# If possible use the version of the remote database, otherwise
# fallback to our local DB version
if $connect_settings != undef and 'DBVERSION' in $connect_settings {
Expand Down
3 changes: 3 additions & 0 deletions manifests/server/extension.pp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
Hash $connect_settings = postgresql::default('default_connect_settings'),
String[1] $database_resource_name = $database,
) {
if $port =~ String {
warning('Passing a string to the port parameter is deprecated. Stdlib::Port will be the enforced datatype in the next major release')
}
$user = postgresql::default('user')
$group = postgresql::default('group')
$psql_path = postgresql::default('psql_path')
Expand Down
3 changes: 3 additions & 0 deletions manifests/server/grant.pp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
String $group = $postgresql::server::group,
Variant[String[1], Stdlib::Absolutepath] $psql_path = $postgresql::server::psql_path,
) {
if $port =~ String {
warning('Passing a string to the port parameter is deprecated. Stdlib::Port will be the enforced datatype in the next major release')
}
case $ensure {
default: {
# default is 'present'
Expand Down
3 changes: 3 additions & 0 deletions manifests/server/grant_role.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
Variant[String[1], Stdlib::Port] $port = $postgresql::server::port,
Hash $connect_settings = $postgresql::server::default_connect_settings,
) {
if $port =~ String {
warning('Passing a string to the port parameter is deprecated. Stdlib::Port will be the enforced datatype in the next major release')
}
case $ensure {
'present': {
$command = "GRANT \"${group}\" TO \"${role}\""
Expand Down
3 changes: 3 additions & 0 deletions manifests/server/instance/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
Optional[Postgresql::Pg_password_encryption] $password_encryption = $postgresql::server::password_encryption,
Optional[String] $extra_systemd_config = $postgresql::server::extra_systemd_config,
) {
if $port =~ String {
warning('Passing a string to the port parameter is deprecated. Stdlib::Port will be the enforced datatype in the next major release')
}
if ($manage_pg_hba_conf == true) {
# Prepare the main pg_hba file
concat { $pg_hba_conf_path:
Expand Down
3 changes: 3 additions & 0 deletions manifests/server/instance/late_initdb.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
Variant[String[1], Stdlib::Port] $port = $postgresql::server::port,
String[1] $module_workdir = $postgresql::server::module_workdir,
) {
if $port =~ String {
warning('Passing a string to the port parameter is deprecated. Stdlib::Port will be the enforced datatype in the next major release')
}
# Set the defaults for the postgresql_psql resource
Postgresql_psql {
psql_user => $user,
Expand Down
3 changes: 3 additions & 0 deletions manifests/server/instance/passwd.pp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
String[1] $module_workdir = $postgresql::server::module_workdir,
Optional[Variant[String[1], Sensitive[String[1]], Integer]] $postgres_password = $postgresql::server::postgres_password,
) {
if $port =~ String {
warning('Passing a string to the port parameter is deprecated. Stdlib::Port will be the enforced datatype in the next major release')
}
$real_postgres_password = if $postgres_password =~ Sensitive {
$postgres_password.unwrap
} else {
Expand Down
3 changes: 3 additions & 0 deletions manifests/server/instance/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
Variant[String[1], Stdlib::Absolutepath] $psql_path = $postgresql::server::psql_path,
Hash $connect_settings = $postgresql::server::default_connect_settings,
) {
if $port =~ String {
warning('Passing a string to the port parameter is deprecated. Stdlib::Port will be the enforced datatype in the next major release')
}
anchor { "postgresql::server::service::begin::${name}": }

if $service_manage {
Expand Down
3 changes: 3 additions & 0 deletions manifests/server/instance/systemd.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
Enum[present, absent] $drop_in_ensure = 'present',

) {
if $port =~ String {
warning('Passing a string to the port parameter is deprecated. Stdlib::Port will be the enforced datatype in the next major release')
}
# Template uses:
# - $port
# - $datadir
Expand Down
3 changes: 3 additions & 0 deletions manifests/server/reassign_owned_by.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
Variant[String[1], Stdlib::Port] $port = $postgresql::server::port,
Hash $connect_settings = $postgresql::server::default_connect_settings,
) {
if $port =~ String {
warning('Passing a string to the port parameter is deprecated. Stdlib::Port will be the enforced datatype in the next major release')
}
$sql_command = "REASSIGN OWNED BY \"${old_role}\" TO \"${new_role}\""

$group = $postgresql::server::group
Expand Down
3 changes: 3 additions & 0 deletions manifests/server/role.pp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
Optional[Enum['md5', 'scram-sha-256']] $hash = undef,
Optional[Variant[String[1], Integer]] $salt = undef,
) {
if $port =~ String {
warning('Passing a string to the port parameter is deprecated. Stdlib::Port will be the enforced datatype in the next major release')
}
$password_hash_unsensitive = if $password_hash =~ Sensitive[String] {
$password_hash.unwrap
} else {
Expand Down
3 changes: 3 additions & 0 deletions manifests/server/table_grant.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
Optional[Hash] $connect_settings = undef,
Boolean $onlyif_exists = false,
) {
if $port =~ String {
warning('Passing a string to the port parameter is deprecated. Stdlib::Port will be the enforced datatype in the next major release')
}
postgresql::server::grant { "table:${name}":
ensure => $ensure,
role => $role,
Expand Down
2 changes: 1 addition & 1 deletion spec/acceptance/alternative_port_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
describe 'postgresql::server' do
it 'on an alternative port' do
pp = <<-MANIFEST
class { 'postgresql::server': port => '55433', manage_selinux => true }
class { 'postgresql::server': port => 55433, manage_selinux => true }
MANIFEST
if os[:family] == 'redhat' && os[:release].start_with?('8')
apply_manifest(pp, expect_failures: false)
Expand Down
4 changes: 2 additions & 2 deletions spec/defines/server/extension_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@
extension: 'pg_repack',
connect_settings: { 'PGHOST' => 'postgres-db-server',
'DBVERSION' => '9.1',
'PGPORT' => '1234' }
'PGPORT' => 1234 }
}
end

Expand All @@ -222,7 +222,7 @@
extension: 'pg_repack',
connect_settings: { 'PGHOST' => 'postgres-db-server',
'DBVERSION' => '9.1',
'PGPORT' => '1234' },
'PGPORT' => 1234 },
port: 5678
}
end
Expand Down
2 changes: 1 addition & 1 deletion spec/defines/server/grant_role_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
let(:params) do
super().merge(psql_db: 'postgres',
psql_user: 'postgres',
port: '5432')
port: 5432)
end

it {
Expand Down

0 comments on commit e5e6309

Please sign in to comment.