]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
monitoring/grafana: remove explicit str casting
authorPere Diaz Bou <pdiazbou@redhat.com>
Mon, 3 Jan 2022 08:32:51 +0000 (09:32 +0100)
committerPere Diaz Bou <pdiazbou@redhat.com>
Tue, 26 Apr 2022 08:50:18 +0000 (10:50 +0200)
Signed-off-by: Pere Diaz Bou <pdiazbou@redhat.com>
monitoring/ceph-mixin/tests_dashboards/util.py

index f9295704b472402a70ca03e10e98603361eebdf4..ce1456c725736fa9d6bc3b9cee4f5662b3f07555 100644 (file)
@@ -93,7 +93,12 @@ def replace_grafana_expr_variables(expr: str, variable: str, value: Any) -> str:
     >>> replace_grafana_expr_variables('metric{name~="no_dollar|$other|$osd"}', \
         'no_dollar', 'replacement')
     'metric{name~="no_dollar|$other|$osd"}'
+
+    It shouldn't replace the next char after the variable (positive lookahead test).
+    >>> replace_grafana_expr_variables('metric{name~="$osd"}', \
+        'osd', 'replacement')
+    'metric{name~="replacement"}'
     """
     regex = fr'\${variable}(?=\W)'
-    new_expr = re.sub(regex, fr'{str(value)}', expr)
+    new_expr = re.sub(regex, fr'{value}', expr)
     return new_expr