diff options
-rw-r--r-- | kvmd/apps/__init__.py | 5 | ||||
-rw-r--r-- | kvmd/apps/kvmd/streamer.py | 8 | ||||
-rw-r--r-- | kvmd/validators/os.py | 8 |
3 files changed, 18 insertions, 3 deletions
diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py index 820278ce..b8a4c160 100644 --- a/kvmd/apps/__init__.py +++ b/kvmd/apps/__init__.py @@ -73,6 +73,7 @@ from ..validators.os import valid_abs_path from ..validators.os import valid_abs_file from ..validators.os import valid_abs_dir from ..validators.os import valid_unix_mode +from ..validators.os import valid_options from ..validators.os import valid_command from ..validators.net import valid_ip_or_host @@ -363,7 +364,9 @@ def _get_config_scheme() -> Dict: "process_name_prefix": Option("kvmd/streamer"), - "cmd": Option(["/bin/true"], type=valid_command), + "cmd": Option(["/bin/true"], type=valid_command), + "cmd_remove": Option([], type=valid_options), + "cmd_append": Option([], type=valid_options), }, "snapshot": { diff --git a/kvmd/apps/kvmd/streamer.py b/kvmd/apps/kvmd/streamer.py index 48336c98..047e4c97 100644 --- a/kvmd/apps/kvmd/streamer.py +++ b/kvmd/apps/kvmd/streamer.py @@ -132,6 +132,8 @@ class Streamer: # pylint: disable=too-many-instance-attributes process_name_prefix: str, cmd: List[str], + cmd_remove: List[str], + cmd_append: List[str], **params_kwargs: Any, ) -> None: @@ -148,7 +150,11 @@ class Streamer: # pylint: disable=too-many-instance-attributes self.__process_name_prefix = process_name_prefix - self.__cmd = cmd + self.__cmd = [ + cmd[0], # Executable + *filter((lambda item: item not in cmd_remove), cmd[1:]), + *cmd_append, + ] self.__params = _StreamerParams(**params_kwargs) diff --git a/kvmd/validators/os.py b/kvmd/validators/os.py index ec8d47fa..67c9b3e1 100644 --- a/kvmd/validators/os.py +++ b/kvmd/validators/os.py @@ -94,8 +94,14 @@ def valid_unix_mode(arg: Any) -> int: return int(valid_number(arg, min=0, name="UNIX mode")) +def valid_options(arg: Any, name: str="") -> List[str]: + if not name: + name = "options" + return valid_string_list(arg, delim=r"[,\t]+", name=name) + + def valid_command(arg: Any) -> List[str]: - cmd = valid_string_list(arg, delim=r"[,\t]+", name="command") + cmd = valid_options(arg, name="command") if len(cmd) == 0: raise_error(arg, "command") cmd[0] = valid_abs_file(cmd[0], name="command entry point") |