From 051540a5c8a76ec746ea3568249072a7ae0732d9 Mon Sep 17 00:00:00 2001 From: Lennart Betz Date: Sun, 31 Dec 2023 10:14:45 +0100 Subject: [PATCH] Replace duplicate function icinga::unwrap with built-in unwrap function --- REFERENCE.md | 19 ------------------- functions/db/connect.pp | 2 +- functions/unwrap.pp | 16 ---------------- manifests/cert.pp | 2 +- manifests/database.pp | 2 +- manifests/init.pp | 2 +- 6 files changed, 4 insertions(+), 39 deletions(-) delete mode 100644 functions/unwrap.pp diff --git a/REFERENCE.md b/REFERENCE.md index 4db1767..5b7743f 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -56,7 +56,6 @@ PHP and a Webserver. with or without TLS information. * [`icinga::newline`](#icinga--newline): Replace newlines for Windows systems. * [`icinga::prepare_web`](#icinga--prepare_web): This funktion checks for web preparation and display a warning if fails -* [`icinga::unwrap`](#icinga--unwrap): This function returns an unwrap string if necessary. ### Data types @@ -2035,24 +2034,6 @@ Data type: `String` -### `icinga::unwrap` - -Type: Puppet Language - -This function returns an unwrap string if necessary. - -#### `icinga::unwrap(Optional[Variant[String, Sensitive[String]]] $arg = undef)` - -The icinga::unwrap function. - -Returns: `Any` The unwraped string. - -##### `arg` - -Data type: `Optional[Variant[String, Sensitive[String]]]` - - - ## Data types ### `Icinga::Certificate` diff --git a/functions/db/connect.pp b/functions/db/connect.pp index 3aa5367..bf19d2e 100644 --- a/functions/db/connect.pp +++ b/functions/db/connect.pp @@ -72,7 +72,7 @@ function icinga::db::connect( 'dbname=' => $db['database'], })), ' '), '= ', '=', 'G') } else { - $_password = icinga::unwrap($db['password']) + $_password = unwrap($db['password']) $options = join(any2array(delete_undef_values({ '-h' => $db['host'] ? { /localhost/ => undef, diff --git a/functions/unwrap.pp b/functions/unwrap.pp deleted file mode 100644 index f55a3d9..0000000 --- a/functions/unwrap.pp +++ /dev/null @@ -1,16 +0,0 @@ -# @summary -# This function returns an unwrap string if necessary. -# -# @return -# The unwraped string. -# -function icinga::unwrap(Optional[Variant[String, Sensitive[String]]] $arg = undef) { - # @param arg - # A sensitive or string. - # - if $arg =~ Sensitive { - $arg.unwrap - } else { - $arg - } -} diff --git a/manifests/cert.pp b/manifests/cert.pp index 092085c..cce2f95 100644 --- a/manifests/cert.pp +++ b/manifests/cert.pp @@ -30,7 +30,7 @@ if $args[key] { file { $args['key_file']: ensure => file, - content => icinga::newline(icinga::unwrap($args['key'])), + content => icinga::newline(unwrap($args['key'])), mode => $key_mode, show_diff => false, } diff --git a/manifests/database.pp b/manifests/database.pp index ce11b14..9d90cf8 100644 --- a/manifests/database.pp +++ b/manifests/database.pp @@ -31,7 +31,7 @@ } if versioncmp($facts['puppetversion'], '6.0.0') < 0 or ($facts['os']['family'] == 'redhat' and Integer($facts['os']['release']['major']) < 8) { - $_pass = icinga::unwrap($db_pass) + $_pass = unwrap($db_pass) } else { $_pass = postgresql::postgresql_password($db_user, $db_pass, false, $postgresql::server::password_encryption) } diff --git a/manifests/init.pp b/manifests/init.pp index bc612bc..3f61ba1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -213,7 +213,7 @@ "${icinga_home}/.ssh/id_${ssh_key_type}": mode => '0600', show_diff => false, - content => icinga::unwrap($ssh_private_key); + content => unwrap($ssh_private_key); "${icinga_home}/.ssh/config": content => "Host *\n StrictHostKeyChecking no\n ControlPath ${icinga_home}/.ssh/controlmasters/%r@%h:%p.socket\n ControlMaster auto\n ControlPersist 5m"; }