This message was deleted.
# puppet
s
This message was deleted.
b
Found a solution after some googling.
$_certificates = $certificates.keys()
$_watch_files = $_certificates.map |$x| { "/etc/letsencrypt/${x}/cert.pem" }
y
you can do in one line with
Copy code
$_watch_files = $certificates.keys().map |$x| { ... }
👍 1
h
also, when chaining function calls like that and there are no arguments to pass in a call, the parentheses can be skipped - thus making it:
$_watch_files = $certificates.keys.map |$x| { ... }
n
And you don't even necessarily need the
keys()
function. Here it is with 1 function call:
Copy code
$certificates = { 'cert1' => {}, 'cert2' => {} }
$_watch_files = $certificates.map |$k, $_v| { "/etc/letsencrypt/${k}/cert.pem" }
Though the clarity of
keys()
is nice.
👍🏻 1
👍 2