From 177cb57f4fc06ebaecace262d3dbd1e417f5cce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 27 Sep 2023 07:04:40 +0200 Subject: Convert to PDK, and fix easy linter errors. --- functions/repack.pp | 4 ++-- manifests/init.pp | 3 +-- manifests/networkd_instance.pp | 31 +++++++++++++++---------------- metadata.json | 5 ++++- pdk.yaml | 2 ++ 5 files changed, 24 insertions(+), 21 deletions(-) create mode 100644 pdk.yaml diff --git a/functions/repack.pp b/functions/repack.pp index a4b7815..1835fa7 100644 --- a/functions/repack.pp +++ b/functions/repack.pp @@ -2,8 +2,8 @@ function networking::repack(Hash[String,Variant[Hash, Array[Hash]]] $data) >> Hash[String, Array[Hash]] { $data.map |$key, $body| { [$key, $body ? { - Hash => [$body], - default => $body, + Hash => [$body], + default => $body, }] }.convert_to(Hash) } diff --git a/manifests/init.pp b/manifests/init.pp index 7dc2450..790c8c0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -2,12 +2,11 @@ class networking ( Optional[Enum['systemd']] $provider = undef, Hash[String,Hash] $items = {}, ) { - # TODO choose a sensible provider here case $provider { 'systemd', undef: { - include ::networking::networkd + include networking::networkd create_resources(networking::networkd_instance, $items) } default: { diff --git a/manifests/networkd_instance.pp b/manifests/networkd_instance.pp index 8a2693d..cbad0a2 100644 --- a/manifests/networkd_instance.pp +++ b/manifests/networkd_instance.pp @@ -9,27 +9,26 @@ define networking::networkd_instance ( String $file = "${path}/${real_filename}", Optional[String] $mode = undef, ) { - file { $file: ensure => $ensure, owner => 'systemd-network', mode => $mode, content => epp('networking/unit_file.epp', { - # Keys are unit file sections - # Values are list of section content, so - # { - # 'Section' => [ - # { - # 'key': 'value', - # 'mvalued': ['v1', 'v2'], - # } - # ] - # } - # [Section] - # key=value - # mvalued=v1 - # mvalued=v2 - data => networking::repack($content), + # Keys are unit file sections + # Values are list of section content, so + # { + # 'Section' => [ + # { + # 'key': 'value', + # 'mvalued': ['v1', 'v2'], + # } + # ] + # } + # [Section] + # key=value + # mvalued=v1 + # mvalued=v2 + data => networking::repack($content), }), notify => if $networking::networkd::notify_ { Exec['reload networkd'] } else { [] }, } diff --git a/metadata.json b/metadata.json index 607c904..ed37a13 100644 --- a/metadata.json +++ b/metadata.json @@ -15,5 +15,8 @@ { "operatingsystem": "Archlinux" } - ] + ], + "pdk-version": "2.5.0", + "template-url": "pdk-default#2.5.0", + "template-ref": "tags/2.5.0-0-g369d483" } diff --git a/pdk.yaml b/pdk.yaml new file mode 100644 index 0000000..4bef4bd --- /dev/null +++ b/pdk.yaml @@ -0,0 +1,2 @@ +--- +ignore: [] -- cgit v1.2.3