Add regex support to template query

This allows us to use the regex feature to extract a substring
result from a variable template query.

Change-Id: If8a8fe4052f18cd37f4b90ba2eb9fc94e19b07ea
This commit is contained in:
James E. Blair
2025-05-08 11:51:33 -07:00
parent 0a344201a2
commit 83dd431a99
3 changed files with 15 additions and 0 deletions

View File

@@ -32,6 +32,7 @@ class Query(Base):
default=1): v.All(int, v.Range(min=0, max=2)),
v.Optional('datasource'): v.All(str),
v.Optional('hide'): v.All(int, v.Range(min=0, max=2)),
v.Optional('regex'): v.All(str),
}
query.update(self.base)
return v.Schema(query)

View File

@@ -47,6 +47,15 @@
"refresh": 2,
"type": "query"
},
{
"includeAll": false,
"multi": false,
"name": "test_query_regex",
"query": "*",
"refresh": 2,
"regex": "/.*?-foo-(.*)/",
"type": "query"
},
{
"current": {
"text": "undercloud",

View File

@@ -7,6 +7,11 @@ dashboard:
type: query
query: "*"
refresh: 2
- name: test_query_regex
type: query
query: "*"
refresh: 2
regex: "/.*?-foo-(.*)/"
- name: test_custom_1
type: custom
options: