Skip to content

Commit

Permalink
update reference.md, fix enum values, fix condition, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonHoenscheid committed Feb 5, 2024
1 parent 4b10348 commit 5bf9c83
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
17 changes: 3 additions & 14 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1695,12 +1695,7 @@ Default value: `'icinga'`

##### <a name="-icinga2--feature--idopgsql--ssl_mode"></a>`ssl_mode`

Data type:

```puppet
Optional[Enum['disable', 'allow', 'prefer',
'verify-full', 'verify-ca', 'require']]
```
Data type: `Optional[Enum['verify-full', 'verify-ca']]`

Enable SSL connection mode.

Expand Down Expand Up @@ -5603,8 +5598,7 @@ with or without TLS information.
database => String,
username => String,
password => Optional[Variant[String, Sensitive[String]]],
}] $db, Hash[String, Any] $tls, Optional[Boolean] $use_tls = undef, Optional[Enum['disable', 'allow', 'prefer',
'verify-full', 'verify-ca', 'require']] $ssl_mode = undef)`
}] $db, Hash[String, Any] $tls, Optional[Boolean] $use_tls = undef, Optional[Enum['verify-full', 'verify-ca']] $ssl_mode = undef)`

The icinga2::db::connect function.

Expand Down Expand Up @@ -5641,12 +5635,7 @@ Wether or not to use TLS encryption.

##### `ssl_mode`

Data type:

```puppet
Optional[Enum['disable', 'allow', 'prefer',
'verify-full', 'verify-ca', 'require']]
```
Data type: `Optional[Enum['verify-full', 'verify-ca']]`

Enable SSL connection mode.

Expand Down
6 changes: 3 additions & 3 deletions functions/db/connect.pp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ function icinga2::db::connect(
}] $db,
Hash[String, Any] $tls,
Optional[Boolean] $use_tls = undef,
Optional[Enum['disable', 'allow', 'prefer',
'verify-full', 'verify-ca', 'require']] $ssl_mode = undef,
Optional[Enum['verify-full', 'verify-ca']] $ssl_mode = undef,
) >> String {
if $use_tls {
case $db['type'] {
'pgsql': {
$real_ssl_mode = if $ssl_mode { $ssl_mode } else { 'verify-full' }
$tls_options = regsubst(join(any2array(delete_undef_values({
'sslmode=' => if $tls['noverify'] { 'require' } else { $ssl_mode },
'sslmode=' => if $tls['noverify'] { 'require' } else { $real_ssl_mode },
'sslcert=' => $tls['cert_file'],
'sslkey=' => $tls['key_file'],
'sslrootcert=' => $tls['cacert_file'],
Expand Down
3 changes: 1 addition & 2 deletions manifests/feature/idopgsql.pp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@
Optional[Stdlib::Port::Unprivileged] $port = undef,
String $user = 'icinga',
String $database = 'icinga',
Optional[Enum['disable', 'allow', 'prefer',
'verify-full', 'verify-ca', 'require']] $ssl_mode = undef,
Optional[Enum['verify-full', 'verify-ca']] $ssl_mode = undef,
Optional[Stdlib::Absolutepath] $ssl_key_path = undef,
Optional[Stdlib::Absolutepath] $ssl_cert_path = undef,
Optional[Stdlib::Absolutepath] $ssl_cacert_path = undef,
Expand Down
4 changes: 2 additions & 2 deletions spec/functions/db_connect_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@
{ 'type' => 'pgsql', 'host' => '192.168.0.1', 'database' => 'foo', 'username' => 'bar', 'password' => 'supersecret' },
{ 'cacert_file' => '/etc/pki/ca-trust/source/anchors/mycacert.crt' },
true,
'ssl_mode' => 'verify-ca',
).and_return('host=db.example.org user=bar dbname=foo sslmode=verify-ca sslrootcert=/etc/pki/ca-trust/source/anchors/mycacert.crt')
'verify-ca',
).and_return('host=192.168.0.1 user=bar dbname=foo sslmode=verify-ca sslrootcert=/etc/pki/ca-trust/source/anchors/mycacert.crt')
end

it 'with PostgreSQL TLS (insecure) on db.example.org and password' do
Expand Down

0 comments on commit 5bf9c83

Please sign in to comment.