Replace forward slash in cluster_name (#3247)

This commit is contained in:
Antoni Mur
2025-01-20 08:57:48 +01:00
committed by GitHub
parent 26ae38960a
commit 3938bb9a16
+2 -1
View File
@@ -2065,9 +2065,10 @@ def invoke_editor(before_editing: str, cluster_name: str) -> Tuple[str, Dict[str
if not editor_cmd: if not editor_cmd:
raise PatroniCtlException('EDITOR environment variable is not set. editor or vi are not available') raise PatroniCtlException('EDITOR environment variable is not set. editor or vi are not available')
safe_cluster_name = cluster_name.replace("/", "_")
with temporary_file(contents=before_editing.encode('utf-8'), with temporary_file(contents=before_editing.encode('utf-8'),
suffix='.yaml', suffix='.yaml',
prefix='{0}-config-'.format(cluster_name)) as tmpfile: prefix='{0}-config-'.format(safe_cluster_name)) as tmpfile:
ret = subprocess.call([editor_cmd, tmpfile]) ret = subprocess.call([editor_cmd, tmpfile])
if ret: if ret:
raise PatroniCtlException("Editor exited with return code {0}".format(ret)) raise PatroniCtlException("Editor exited with return code {0}".format(ret))