From 45452b916dafd0bd850b532a0ea5461b7327708b Mon Sep 17 00:00:00 2001 From: Pere Diaz Bou Date: Mon, 3 Jan 2022 09:32:51 +0100 Subject: [PATCH] monitoring/grafana: remove explicit str casting Signed-off-by: Pere Diaz Bou --- monitoring/ceph-mixin/tests_dashboards/util.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/monitoring/ceph-mixin/tests_dashboards/util.py b/monitoring/ceph-mixin/tests_dashboards/util.py index f9295704b4724..ce1456c725736 100644 --- a/monitoring/ceph-mixin/tests_dashboards/util.py +++ b/monitoring/ceph-mixin/tests_dashboards/util.py @@ -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 -- 2.39.5