mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
committed by
Alexander Kukushkin
parent
1a6db4f5af
commit
78999a2d62
+10
-2
@@ -25,6 +25,7 @@ import yaml
|
||||
|
||||
from click import ClickException
|
||||
from contextlib import contextmanager
|
||||
from distutils.spawn import find_executable
|
||||
from patroni.config import Config
|
||||
from patroni.dcs import get_dcs as _get_dcs
|
||||
from patroni.exceptions import PatroniException
|
||||
@@ -1088,9 +1089,16 @@ def invoke_editor(before_editing, cluster_name):
|
||||
:param before_editing: human representation before editing
|
||||
:returns tuple of human readable and parsed datastructure after changes
|
||||
"""
|
||||
editor_cmd = os.environ.get('EDITOR')
|
||||
if 'EDITOR' in os.environ:
|
||||
editor_cmd = os.environ.get('EDITOR')
|
||||
else:
|
||||
for editor in ('editor', 'vi'):
|
||||
editor_cmd = find_executable(editor)
|
||||
if editor_cmd:
|
||||
logging.debug('Setting fallback editor_cmd=%s', editor)
|
||||
break
|
||||
if not editor_cmd:
|
||||
raise PatroniCtlException('EDITOR environment variable is not set')
|
||||
raise PatroniCtlException('EDITOR environment variable is not set. editor or vi are not available')
|
||||
|
||||
with temporary_file(contents=before_editing.encode('utf-8'),
|
||||
suffix='.yaml',
|
||||
|
||||
Reference in New Issue
Block a user