From eb38e6252b3c52a44d0d33679b3bc3178674c7f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Fri, 5 May 2023 00:31:37 +0200 Subject: Everything --- functions/convert_to_rname.pp | 10 ++++++++++ functions/ensure_ending_period.pp | 8 ++++++++ 2 files changed, 18 insertions(+) create mode 100644 functions/convert_to_rname.pp create mode 100644 functions/ensure_ending_period.pp (limited to 'functions') diff --git a/functions/convert_to_rname.pp b/functions/convert_to_rname.pp new file mode 100644 index 0000000..fc3113d --- /dev/null +++ b/functions/convert_to_rname.pp @@ -0,0 +1,10 @@ +# Converts regular email addresses to dns format +function dns::convert_to_rname(String $x) >> String { + $s = if $x =~ /([^@]*)@(.*)/ { + "${1}.${2}" + } else { + $x + } + + dns::ensure_ending_period($s) +} diff --git a/functions/ensure_ending_period.pp b/functions/ensure_ending_period.pp new file mode 100644 index 0000000..76c0003 --- /dev/null +++ b/functions/ensure_ending_period.pp @@ -0,0 +1,8 @@ +# Adds a period to end of string if not already present +function dns::ensure_ending_period(String $s) >> String { + if $s[-1] == '.' { + $s + } else { + "${s}." + } +} -- cgit v1.2.3