From 20ae18e064fe24912d30ca9b4123e5492fc5f971 Mon Sep 17 00:00:00 2001 From: s3lph Date: Sun, 1 Sep 2019 23:24:23 +0200 Subject: [PATCH] Fix: Ensure scrape interval is positive --- icalendar-timeseries-server.json | 32 --------------------------- icalendar_timeseries_server/config.py | 3 ++- 2 files changed, 2 insertions(+), 33 deletions(-) delete mode 100644 icalendar-timeseries-server.json diff --git a/icalendar-timeseries-server.json b/icalendar-timeseries-server.json deleted file mode 100644 index 847ee7d..0000000 --- a/icalendar-timeseries-server.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "addr": "127.0.0.1", - "port": 8090, - "start_delta": "-PT3H", - "end_delta": "P60D", - "cache": "PT3M", - "tz": "Europe/Zurich", - "calendars": { - "tlstest": { - "interval": "PT5M", - "url": "https://localhost/private.ics", - "ca": "/home/sebastian/tlstest/ca/ca/ca.crt", - "auth": { - "type": "tls", - "keyfile": "/home/sebastian/tlstest/client/combined.pem" - } - }, - "filetest": { - "interval": "PT1M", - "url": "file:///srv/http/private.ics" - } - }, - "key_replace": { - "summary": "a_summary", - "description": "b_description" - }, - "value_replace": { - "summary": "{{ summary|truncate(100, end=' \\N{HORIZONTAL ELLIPSIS}') }}", - "description": "{{ description|truncate(100, end=' \\N{HORIZONTAL ELLIPSIS}') }}", - "useless_metric": "{{ start.timestamp() + end.timestamp() }}" - } -} diff --git a/icalendar_timeseries_server/config.py b/icalendar_timeseries_server/config.py index 81cc795..c3d18df 100644 --- a/icalendar_timeseries_server/config.py +++ b/icalendar_timeseries_server/config.py @@ -28,7 +28,8 @@ class CalendarConfig: def __init__(self, config: Dict[str, Any], config_path: str) -> None: self._url: str = _keycheck('url', config, str, config_path) - self._scrape_interval: Duration = _parse_timedelta('interval', config, config_path, default_value='PT15M') + self._scrape_interval: Duration = _parse_timedelta('interval', config, config_path, default_value='PT15M', + force_positive=True) self._ca: Optional[str] = _keycheck('ca', config, str, config_path, optional=True) auth: Dict[str, Any] = _keycheck('auth', config, dict, config_path, default_value={'type': 'none'}) self._authtype: str = _keycheck('type', auth, str, f'{config_path}.auth',