From e15e7a17ab4d08f7069eabf28495e8e698469665 Mon Sep 17 00:00:00 2001 From: Ruslan Aliev Date: Fri, 12 Sep 2025 15:33:11 -0500 Subject: [PATCH] Allow to extract data from config files using jsonpath Procides opportunity to extract the specific field from any kind of document using jsonpath. Change-Id: I870cb265f768c6f55b78818ea834b9a79f78630a Signed-off-by: Ruslan Aliev --- promenade/config.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/promenade/config.py b/promenade/config.py index 59bfaaf6..1c4c7baf 100644 --- a/promenade/config.py +++ b/promenade/config.py @@ -84,11 +84,20 @@ class Configuration: return jinja2.StrictUndefined( 'Nothing found matching paths: %s' % ','.join(paths)) - def get(self, *, kind=None, name=None, schema=None, default=None): + def get(self, + *, + kind=None, + name=None, + schema=None, + jsonpath=None, + default=None): result = _get(self.documents, kind=kind, schema=schema, name=name) if result: - return result['data'] + data = result['data'] + if jsonpath: + return _extract(data, jsonpath) + return data else: if default is not None: return default