Skip to content

Commit

Permalink
port: Enforce Stdlib::Port datatype
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Aug 30, 2023
1 parent e9e0ee9 commit 11f52ea
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 68 deletions.
24 changes: 12 additions & 12 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ Default value: `$postgresql::params::listen_addresses`

##### <a name="-postgresql--server--port"></a>`port`

Data type: `Variant[String[1], Stdlib::Port]`
Data type: `Stdlib::Port`

Specifies the port for the PostgreSQL server to listen on.
Note: The same port number is used for all IP addresses the server listens on.
Expand Down Expand Up @@ -1946,7 +1946,7 @@ Default value: `$postgresql::server::psql_path`

##### <a name="-postgresql--server--default_privileges--port"></a>`port`

Data type: `Variant[String[1], Stdlib::Port]`
Data type: `Stdlib::Port`

Specifies the port to access the server. Default value: The default user for the module, usually '5432'.

Expand Down Expand Up @@ -2051,7 +2051,7 @@ Default value: `undef`

##### <a name="-postgresql--server--extension--port"></a>`port`

Data type: `Optional[Variant[String[1], Stdlib::Port]]`
Data type: `Optional[Stdlib::Port]`

Port to use when connecting.

Expand Down Expand Up @@ -2178,7 +2178,7 @@ Default value: `$postgresql::server::user`

##### <a name="-postgresql--server--grant--port"></a>`port`

Data type: `Variant[String[1], Stdlib::Port]`
Data type: `Stdlib::Port`

Port to use when connecting.

Expand Down Expand Up @@ -2280,7 +2280,7 @@ Default value: `$postgresql::server::user`

##### <a name="-postgresql--server--grant_role--port"></a>`port`

Data type: `Variant[String[1], Stdlib::Port]`
Data type: `Stdlib::Port`

Port to use when connecting.

Expand Down Expand Up @@ -2361,7 +2361,7 @@ Default value: `$postgresql::server::listen_addresses`

##### <a name="-postgresql--server--instance--config--port"></a>`port`

Data type: `Variant[String[1], Stdlib::Port]`
Data type: `Stdlib::Port`

Specifies the port for the PostgreSQL server to listen on.
Note: The same port number is used for all IP addresses the server listens on. Also, for Red Hat systems and early Debian systems,
Expand Down Expand Up @@ -2785,7 +2785,7 @@ Default value: `$postgresql::server::psql_path`

##### <a name="-postgresql--server--instance--late_initdb--port"></a>`port`

Data type: `Variant[String[1], Stdlib::Port]`
Data type: `Stdlib::Port`

Specifies the port for the PostgreSQL server to listen on.
Note: The same port number is used for all IP addresses the server listens on. Also, for Red Hat systems and early Debian systems,
Expand Down Expand Up @@ -2844,7 +2844,7 @@ Default value: `$postgresql::server::psql_path`

##### <a name="-postgresql--server--instance--passwd--port"></a>`port`

Data type: `Variant[String[1], Stdlib::Port]`
Data type: `Stdlib::Port`

Specifies the port for the PostgreSQL server to listen on.
Note: The same port number is used for all IP addresses the server listens on. Also, for Red Hat systems and early Debian systems,
Expand Down Expand Up @@ -2982,7 +2982,7 @@ Default value: `$postgresql::server::user`

##### <a name="-postgresql--server--instance--service--port"></a>`port`

Data type: `Variant[String[1], Stdlib::Port]`
Data type: `Stdlib::Port`

Specifies the port for the PostgreSQL server to listen on.
Note: The same port number is used for all IP addresses the server listens on. Also, for Red Hat systems and early Debian systems,
Expand Down Expand Up @@ -3219,7 +3219,7 @@ Default value: `$postgresql::server::user`

##### <a name="-postgresql--server--reassign_owned_by--port"></a>`port`

Data type: `Variant[String[1], Stdlib::Port]`
Data type: `Stdlib::Port`

Port to use when connecting.

Expand Down Expand Up @@ -3465,7 +3465,7 @@ Default value: `$postgresql::server::default_database`

##### <a name="-postgresql--server--role--port"></a>`port`

Data type: `Optional[Variant[String[1], Stdlib::Port]]`
Data type: `Optional[Stdlib::Port]`

Port to use when connecting.

Expand Down Expand Up @@ -3700,7 +3700,7 @@ Default value: `undef`

##### <a name="-postgresql--server--table_grant--port"></a>`port`

Data type: `Optional[Variant[String[1], Stdlib::Port]]`
Data type: `Optional[Stdlib::Port]`

Port to use when connecting.

Expand Down
5 changes: 1 addition & 4 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
String[1] $default_database = $postgresql::params::default_database,
Hash $default_connect_settings = $postgresql::globals::default_connect_settings,
Optional[Variant[String[1], Array[String[1]]]] $listen_addresses = $postgresql::params::listen_addresses,
Variant[String[1], Stdlib::Port] $port = $postgresql::params::port,
Stdlib::Port $port = $postgresql::params::port,
String[1] $ip_mask_deny_postgres_user = $postgresql::params::ip_mask_deny_postgres_user,
String[1] $ip_mask_allow_all_users = $postgresql::params::ip_mask_allow_all_users,
Array[String[1]] $ipv4acls = $postgresql::params::ipv4acls,
Expand Down Expand Up @@ -196,9 +196,6 @@
#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
5 changes: 1 addition & 4 deletions manifests/server/default_privileges.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,13 @@
String $schema = 'public',
String $psql_db = $postgresql::server::default_database,
String $psql_user = $postgresql::server::user,
Variant[String[1], Stdlib::Port] $port = $postgresql::server::port,
Stdlib::Port $port = $postgresql::server::port,
Hash $connect_settings = $postgresql::server::default_connect_settings,
Enum['present', 'absent'] $ensure = 'present',
String $group = $postgresql::server::group,
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
5 changes: 1 addition & 4 deletions manifests/server/extension.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,10 @@
Optional[String[1]] $version = undef,
Enum['present', 'absent'] $ensure = 'present',
Optional[String[1]] $package_name = undef,
Optional[Variant[String[1], Stdlib::Port]] $port = undef,
Optional[Stdlib::Port] $port = undef,
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
5 changes: 1 addition & 4 deletions manifests/server/grant.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,13 @@
Array[String[1],0] $object_arguments = [],
String $psql_db = $postgresql::server::default_database,
String $psql_user = $postgresql::server::user,
Variant[String[1], Stdlib::Port] $port = $postgresql::server::port,
Stdlib::Port $port = $postgresql::server::port,
Boolean $onlyif_exists = false,
Hash $connect_settings = $postgresql::server::default_connect_settings,
Enum['present', 'absent'] $ensure = 'present',
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
5 changes: 1 addition & 4 deletions manifests/server/grant_role.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@
Enum['present', 'absent'] $ensure = 'present',
String[1] $psql_db = $postgresql::server::default_database,
String[1] $psql_user = $postgresql::server::user,
Variant[String[1], Stdlib::Port] $port = $postgresql::server::port,
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
5 changes: 1 addition & 4 deletions manifests/server/instance/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
String[1] $ip_mask_deny_postgres_user = $postgresql::server::ip_mask_deny_postgres_user,
String[1] $ip_mask_allow_all_users = $postgresql::server::ip_mask_allow_all_users,
Optional[Variant[String[1], Array[String[1]]]] $listen_addresses = $postgresql::server::listen_addresses,
Variant[String[1], Stdlib::Port] $port = $postgresql::server::port,
Stdlib::Port $port = $postgresql::server::port,
Array[String[1]] $ipv4acls = $postgresql::server::ipv4acls,
Array[String[1]] $ipv6acls = $postgresql::server::ipv6acls,
Variant[String[1], Stdlib::Absolutepath] $pg_hba_conf_path = $postgresql::server::pg_hba_conf_path,
Expand All @@ -73,9 +73,6 @@
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
5 changes: 1 addition & 4 deletions manifests/server/instance/late_initdb.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@
String[1] $user = $postgresql::server::user,
String[1] $group = $postgresql::server::group,
Variant[String[1], Stdlib::Absolutepath] $psql_path = $postgresql::server::psql_path,
Variant[String[1], Stdlib::Port] $port = $postgresql::server::port,
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
5 changes: 1 addition & 4 deletions manifests/server/instance/passwd.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@
String[1] $user = $postgresql::server::user,
String[1] $group = $postgresql::server::group,
Variant[String[1], Stdlib::Absolutepath] $psql_path = $postgresql::server::psql_path,
Variant[String[1], Stdlib::Port] $port = $postgresql::server::port,
Stdlib::Port $port = $postgresql::server::port,
String[1] $database = $postgresql::server::default_database,
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
5 changes: 1 addition & 4 deletions manifests/server/instance/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,11 @@
Optional[String[1]] $service_provider = $postgresql::server::service_provider,
String[1] $service_status = $postgresql::server::service_status,
String[1] $user = $postgresql::server::user,
Variant[String[1], Stdlib::Port] $port = $postgresql::server::port,
Stdlib::Port $port = $postgresql::server::port,
String[1] $default_database = $postgresql::server::default_database,
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
6 changes: 1 addition & 5 deletions manifests/server/instance/systemd.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
# @param drop_in_ensure sets the Systemd drop-in file to present or absent
# @api private
define postgresql::server::instance::systemd (
Variant[String[1], Stdlib::Port] $port,
Stdlib::Port $port,
Stdlib::Absolutepath $datadir,
Optional[String[1]] $extra_systemd_config = undef,
String[1] $service_name = $name,
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
7 changes: 2 additions & 5 deletions manifests/server/reassign_owned_by.pp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@
String $new_role,
String $db,
String $psql_user = $postgresql::server::user,
Variant[String[1], Stdlib::Port] $port = $postgresql::server::port,
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 All @@ -27,7 +24,7 @@
#
# Port, order of precedence: $port parameter, $connect_settings[PGPORT], $postgresql::server::port
#
if $port != undef {
if $port {
$port_override = $port
} elsif $connect_settings != undef and 'PGPORT' in $connect_settings {
$port_override = undef
Expand Down
7 changes: 2 additions & 5 deletions manifests/server/role.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Boolean $createdb = false,
Boolean $createrole = false,
String[1] $db = $postgresql::server::default_database,
Optional[Variant[String[1], Stdlib::Port]] $port = undef,
Optional[Stdlib::Port] $port = undef,
Boolean $login = true,
Boolean $inherit = true,
Boolean $superuser = false,
Expand All @@ -45,9 +45,6 @@
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 All @@ -56,7 +53,7 @@
#
# Port, order of precedence: $port parameter, $connect_settings[PGPORT], $postgresql::server::port
#
if $port != undef {
if $port {
$port_override = $port
} elsif $connect_settings != undef and 'PGPORT' in $connect_settings {
$port_override = undef
Expand Down
5 changes: 1 addition & 4 deletions manifests/server/table_grant.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@
String[1] $db,
String[1] $role,
Optional[Enum['present', 'absent']] $ensure = undef,
Optional[Variant[String[1], Stdlib::Port]] $port = undef,
Optional[Stdlib::Port] $port = undef,
Optional[String[1]] $psql_db = undef,
Optional[String[1]] $psql_user = undef,
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 templates/systemd-override.conf.epp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%- |
Variant[String[1], Stdlib::Port] $port,
Stdlib::Port $port,
Stdlib::Absolutepath $datadir,
Optional[String[1]] $extra_systemd_config,
| -%>
Expand Down

0 comments on commit 11f52ea

Please sign in to comment.