From f2ef1c6ea7746cc4b2b5aaaac49e2ac6f050a107 Mon Sep 17 00:00:00 2001 From: Lennart Betz Date: Fri, 1 Sep 2023 11:21:15 +0200 Subject: [PATCH] add feature to use attributes from host and service objects in data type Interval --- spec/type_aliases/interval_spec.rb | 4 ++-- types/interval.pp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/type_aliases/interval_spec.rb b/spec/type_aliases/interval_spec.rb index a2ddef3a..fb4c748f 100644 --- a/spec/type_aliases/interval_spec.rb +++ b/spec/type_aliases/interval_spec.rb @@ -4,7 +4,7 @@ describe 'Icinga2::Interval' do describe 'valid handling' do - [60, '3d', '3.5d', '4h', '4.1h', '5m', '5.2m', '60s', '60.4', '300', '300.25', '$macro$'].each do |value| + [60, '3d', '3.5d', '4h', '4.1h', '5m', '5.2m', '60s', '60.4', '300', '300.25', '$macro$', 'host.foo', 'service.foo'].each do |value| describe value.inspect do it { is_expected.to allow_value(value) } end @@ -13,7 +13,7 @@ describe 'invalid path handling' do context 'garbage inputs' do - [nil, '', 'm', 'foo', '2h4' ].each do |value| + [nil, '', 'm', 'foo', '2h4', 'host.', 'service.'].each do |value| describe value.inspect do it { is_expected.not_to allow_value(value) } end diff --git a/types/interval.pp b/types/interval.pp index 34d8db58..896f0a29 100644 --- a/types/interval.pp +++ b/types/interval.pp @@ -1,2 +1,2 @@ # A strict type for intervals -type Icinga2::Interval = Variant[Integer, Pattern[/\A\d+\.?\d*[d|h|m|s]?\Z/, /\A\$.+\$\Z/]] +type Icinga2::Interval = Variant[Integer, Pattern[/\A\d+\.?\d*[d|h|m|s]?\Z/, /\A\$.+\$\Z/, /\A(host|service)\..+/]]