Skip to content

port parameter: log warning when its a string #1474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
deprecation('postgres_port', '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 {
deprecation('postgres_port', '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 {
deprecation('postgres_port', '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 {
deprecation('postgres_port', '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 {
deprecation('postgres_port', '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 {
deprecation('postgres_port', '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 {
deprecation('postgres_port', '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 {
deprecation('postgres_port', '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 {
deprecation('postgres_port', '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 {
deprecation('postgres_port', '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 {
deprecation('postgres_port', '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 {
deprecation('postgres_port', '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 {
deprecation('postgres_port', '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