Skip to content
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

Set data types for puppetdb parameters #411

Open
wants to merge 32 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a6053be
set data type for port params
chambersmp May 27, 2024
a660089
convert string port values to integer
chambersmp May 27, 2024
89fe403
remove `port` variable as database_port is an integer
chambersmp May 27, 2024
dcaa056
set param database_port as integer
chambersmp May 27, 2024
8708434
set boolean data type validation for puppetdb params
chambersmp May 27, 2024
0498e87
set absolutepath validation for file path params
chambersmp May 27, 2024
d100da2
style: remove newline
chambersmp May 27, 2024
7d024df
set integer data validation and update string params to integer
chambersmp May 28, 2024
93a4a3d
set hash and array data validation for params
chambersmp May 28, 2024
33be72e
set String data validation for params
chambersmp May 28, 2024
6386cde
set string, enum and optional data types
chambersmp May 29, 2024
d8abfca
add variant patterns for integers and port values as strings to suppo…
chambersmp May 29, 2024
d289f28
restore original params values
chambersmp May 29, 2024
02a4abd
restore original postgresql_spec params
chambersmp May 29, 2024
b2d7841
confine ports to unprivileged values
chambersmp May 30, 2024
84b2d79
set data type assertions for server params
chambersmp May 31, 2024
94fd634
style: align parameters
chambersmp May 31, 2024
0371ea9
set data type assertions for globals params
chambersmp May 31, 2024
0b9fc4e
set jdbc ssl properties to accept string and boolean values
chambersmp Jun 6, 2024
5e67290
set data validation to align with init params
chambersmp Jun 6, 2024
059a191
set data validation for defined types
chambersmp Jun 6, 2024
3ebfe40
set data validation for database ssl configuration
chambersmp Jun 6, 2024
148243e
set puppetdb_server type to stdlib::host, update test to use fqdn or …
chambersmp Jun 6, 2024
31eab60
set type validation for master sub classes
chambersmp Jun 6, 2024
723693f
set data type validation for server sub classes
chambersmp Jun 6, 2024
1f9d70b
set date type validation for server and server database classes
chambersmp Jun 6, 2024
79b8248
set data type validation for optional params
chambersmp Jun 6, 2024
2f017f4
add pattern variant for integer as strings for acceptance test
chambersmp Jun 6, 2024
4b76eb7
refine port validation to user ports 1024-49151
chambersmp Jun 7, 2024
62ae1ef
set lower bounds for string and integer to negate empty or negative v…
chambersmp Jun 11, 2024
bb980c1
set open_ssl_port to default false instead of undef
chambersmp Jul 1, 2024
afecff8
set open_ssl_port to false instead of nil for unit test shared examples
chambersmp Jul 1, 2024
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
8 changes: 4 additions & 4 deletions manifests/database/default_read_grant.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#
# @api private
define puppetdb::database::default_read_grant (
String $database_name,
String $schema,
String $database_username,
String $database_read_only_username,
String[1] $database_name,
String $schema,
chambersmp marked this conversation as resolved.
Show resolved Hide resolved
String[1] $database_username,
String[1] $database_read_only_username,
Optional[Stdlib::Port] $database_port = undef,
) {
postgresql_psql { "grant default select permission for ${database_read_only_username}":
Expand Down
43 changes: 23 additions & 20 deletions manifests/database/postgresql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,30 @@
# PostgreSQL password authentication method, either `md5` or `scram-sha-256`
#
class puppetdb::database::postgresql (
$listen_addresses = $puppetdb::params::database_host,
$puppetdb_server = $puppetdb::params::puppetdb_server,
$database_name = $puppetdb::params::database_name,
$database_username = $puppetdb::params::database_username,
Variant[String[1], Sensitive[String[1]]] $database_password = $puppetdb::params::database_password,
$database_port = $puppetdb::params::database_port,
$manage_database = $puppetdb::params::manage_database,
$manage_server = $puppetdb::params::manage_dbserver,
$manage_package_repo = $puppetdb::params::manage_pg_repo,
$postgres_version = $puppetdb::params::postgres_version,
$postgresql_ssl_on = $puppetdb::params::postgresql_ssl_on,
$postgresql_ssl_key_path = $puppetdb::params::postgresql_ssl_key_path,
$postgresql_ssl_cert_path = $puppetdb::params::postgresql_ssl_cert_path,
$postgresql_ssl_ca_cert_path = $puppetdb::params::postgresql_ssl_ca_cert_path,
$read_database_username = $puppetdb::params::read_database_username,
Variant[String[1], Sensitive[String[1]]] $read_database_password = $puppetdb::params::read_database_password,
$read_database_host = $puppetdb::params::read_database_host,
Boolean $password_sensitive = false,
Postgresql::Pg_password_encryption $password_encryption = $puppetdb::params::password_encryption,
Stdlib::Host $listen_addresses = $puppetdb::params::database_host,
Stdlib::Host $puppetdb_server = $puppetdb::params::puppetdb_server,
String[1] $database_name = $puppetdb::params::database_name,
String[1] $database_username = $puppetdb::params::database_username,
Variant[String[1], Sensitive[String[1]]] $database_password = $puppetdb::params::database_password,
Variant[Stdlib::Port::User, Pattern[/\A[0-9]+\Z/]] $database_port = $puppetdb::params::database_port,
Boolean $manage_database = $puppetdb::params::manage_database,
Boolean $manage_server = $puppetdb::params::manage_dbserver,
Boolean $manage_package_repo = $puppetdb::params::manage_pg_repo,
String[2,3] $postgres_version = $puppetdb::params::postgres_version,
Boolean $postgresql_ssl_on = $puppetdb::params::postgresql_ssl_on,
Stdlib::Absolutepath $postgresql_ssl_key_path = $puppetdb::params::postgresql_ssl_key_path,
Stdlib::Absolutepath $postgresql_ssl_cert_path = $puppetdb::params::postgresql_ssl_cert_path,
Stdlib::Absolutepath $postgresql_ssl_ca_cert_path = $puppetdb::params::postgresql_ssl_ca_cert_path,
String[1] $read_database_username = $puppetdb::params::read_database_username,
Variant[String[1], Sensitive[String[1]]] $read_database_password = $puppetdb::params::read_database_password,
Optional[Stdlib::Host] $read_database_host = $puppetdb::params::read_database_host,
Boolean $password_sensitive = false,
Postgresql::Pg_password_encryption $password_encryption = $puppetdb::params::password_encryption,
) inherits puppetdb::params {
$port = scanf($database_port, '%i')[0]
$port = case $database_port.is_a(String) {
chambersmp marked this conversation as resolved.
Show resolved Hide resolved
true: { scanf($database_port, '%i')[0] }
default: { $database_port }
}

if $manage_server {
class { 'postgresql::globals':
Expand Down
6 changes: 3 additions & 3 deletions manifests/database/postgresql_ssl_rules.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#
# @api private
define puppetdb::database::postgresql_ssl_rules (
String $database_name,
String $database_username,
String $database_name,
String $database_username,
chambersmp marked this conversation as resolved.
Show resolved Hide resolved
String[2,3] $postgres_version,
String $puppetdb_server,
String $puppetdb_server,
chambersmp marked this conversation as resolved.
Show resolved Hide resolved
) {
$identity_map_key = "${database_name}-${database_username}-map"

Expand Down
6 changes: 3 additions & 3 deletions manifests/database/read_grant.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#
# @api private
define puppetdb::database::read_grant (
String $database_name,
String $schema,
String $database_read_only_username,
String $database_name,
String $schema,
String $database_read_only_username,
chambersmp marked this conversation as resolved.
Show resolved Hide resolved
Optional[Stdlib::Port] $database_port = undef,
) {
postgresql_psql { "grant select permission for ${database_read_only_username}":
Expand Down
12 changes: 6 additions & 6 deletions manifests/database/read_only_user.pp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
#
# @api private
define puppetdb::database::read_only_user (
String $read_database_username,
String $database_name,
String $database_owner,
Variant[String[1], Boolean, Sensitive[String[1]]] $password_hash = false,
Optional[Stdlib::Port] $database_port = undef,
Optional[Postgresql::Pg_password_encryption] $password_encryption = undef,
String[1] $read_database_username,
String[1] $database_name,
String[1] $database_owner,
Variant[String[1], Boolean, Sensitive[String[1]]] $password_hash = false,
Optional[Stdlib::Port] $database_port = undef,
Optional[Postgresql::Pg_password_encryption] $password_encryption = undef,
) {
postgresql::server::role { $read_database_username:
password_hash => $password_hash,
Expand Down
20 changes: 10 additions & 10 deletions manifests/database/ssl_configuration.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
#
# @api private
class puppetdb::database::ssl_configuration (
$database_name = $puppetdb::params::database_name,
$database_username = $puppetdb::params::database_username,
$read_database_username = $puppetdb::params::read_database_username,
$read_database_host = $puppetdb::params::read_database_host,
$puppetdb_server = $puppetdb::params::puppetdb_server,
$postgresql_ssl_key_path = $puppetdb::params::postgresql_ssl_key_path,
$postgresql_ssl_cert_path = $puppetdb::params::postgresql_ssl_cert_path,
$postgresql_ssl_ca_cert_path = $puppetdb::params::postgresql_ssl_ca_cert_path,
$postgres_version = $puppetdb::params::postgres_version,
$create_read_user_rule = false,
String[1] $database_name = $puppetdb::params::database_name,
String[1] $database_username = $puppetdb::params::database_username,
String[1] $read_database_username = $puppetdb::params::read_database_username,
Optional[Stdlib::Host] $read_database_host = $puppetdb::params::read_database_host,
String[1] $puppetdb_server = $puppetdb::params::puppetdb_server,
Stdlib::Absolutepath $postgresql_ssl_key_path = $puppetdb::params::postgresql_ssl_key_path,
Stdlib::Absolutepath $postgresql_ssl_cert_path = $puppetdb::params::postgresql_ssl_cert_path,
Stdlib::Absolutepath $postgresql_ssl_ca_cert_path = $puppetdb::params::postgresql_ssl_ca_cert_path,
String[2,3] $postgres_version = $puppetdb::params::postgres_version,
Boolean $create_read_user_rule = false,
) inherits puppetdb::params {
File {
ensure => present,
Expand Down
2 changes: 1 addition & 1 deletion manifests/globals.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Puppet's config directory. Defaults to `/etc/puppetlabs/puppet`.
#
class puppetdb::globals (
$version = 'present',
String[1] $version = 'present',
Stdlib::Absolutepath $puppet_confdir = $settings::confdir,
) {
if !(fact('os.family') in ['RedHat', 'Suse', 'Archlinux', 'Debian', 'OpenBSD', 'FreeBSD']) {
Expand Down
Loading
Loading