From 3dde6770b905594b5dd38bc5b5f4d3effc0cabc9 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Mon, 20 Mar 2023 22:01:26 +0100 Subject: [PATCH] Allow EnvironmentFile to be an array It's valid to set EnvironmentFile multiple times and this reflects that possibility. It also enhances the regex to at least require one character, so that -/ is considered invalid. --- REFERENCE.md | 2 +- spec/type_aliases/systemd_unit_service_spec.rb | 2 ++ types/unit/service.pp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index 0e9397a1..15e1c69d 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -2182,7 +2182,7 @@ Struct[{ Optional['OOMPolicy'] => Enum['continue', 'stop','kill'], Optional['OOMScoreAdjust'] => Integer[-1000,1000], Optional['Environment'] => String, - Optional['EnvironmentFile'] => Variant[Stdlib::Unixpath,Pattern[/-\/.*/]], + Optional['EnvironmentFile'] => Variant[Stdlib::Unixpath,Pattern[/-\/.+/], Array[Stdlib::Unixpath,Pattern[/-\/.+/],1]], }] ``` diff --git a/spec/type_aliases/systemd_unit_service_spec.rb b/spec/type_aliases/systemd_unit_service_spec.rb index d28db960..5234e514 100644 --- a/spec/type_aliases/systemd_unit_service_spec.rb +++ b/spec/type_aliases/systemd_unit_service_spec.rb @@ -19,5 +19,7 @@ it { is_expected.to allow_value({ 'EnvironmentFile' => '/etc/sysconfig/foo' }) } it { is_expected.to allow_value({ 'EnvironmentFile' => '-/etc/sysconfig/foo' }) } + it { is_expected.to allow_value({ 'EnvironmentFile' => ['/etc/sysconfig/foo', '-/etc/sysconfig/foo-bar'] }) } + it { is_expected.not_to allow_value({ 'EnvironmentFile' => '-/' }) } it { is_expected.not_to allow_value({ 'EnvironmentFile' => 'relative-path.sh' }) } end diff --git a/types/unit/service.pp b/types/unit/service.pp index f2f77c41..cf44720a 100644 --- a/types/unit/service.pp +++ b/types/unit/service.pp @@ -40,6 +40,6 @@ Optional['OOMPolicy'] => Enum['continue', 'stop','kill'], Optional['OOMScoreAdjust'] => Integer[-1000,1000], Optional['Environment'] => String, - Optional['EnvironmentFile'] => Variant[Stdlib::Unixpath,Pattern[/-\/.*/]], + Optional['EnvironmentFile'] => Variant[Stdlib::Unixpath,Pattern[/-\/.+/], Array[Stdlib::Unixpath,Pattern[/-\/.+/],1]], } ]