From 63d50b862c5e995ebd4d7267bfd04a38197b781e Mon Sep 17 00:00:00 2001 From: Miroslav Lisik Date: Wed, 13 May 2026 13:36:46 +0200 Subject: [PATCH 1/2] fix typo 'secretes' => 'secrets' --- pcs/cli/common/parse_args.py | 2 +- pcs_test/tier0/cli/common/test_parse_args.py | 1 + typos.toml | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pcs/cli/common/parse_args.py b/pcs/cli/common/parse_args.py index f9491c51f..5221c3afb 100644 --- a/pcs/cli/common/parse_args.py +++ b/pcs/cli/common/parse_args.py @@ -567,7 +567,7 @@ def __init__(self, options: Mapping[str, ModifierValueType]): "--pacemaker": "--pacemaker" in options, "--promoted": "--promoted" in options, "--safe": "--safe" in options, - "--show-secrets": "--show-secretes" in options, + "--show-secrets": "--show-secrets" in options, "--simulate": "--simulate" in options, "--skip-offline": "--skip-offline" in options, "--start": "--start" in options, diff --git a/pcs_test/tier0/cli/common/test_parse_args.py b/pcs_test/tier0/cli/common/test_parse_args.py index 1119748a0..747a69dfb 100644 --- a/pcs_test/tier0/cli/common/test_parse_args.py +++ b/pcs_test/tier0/cli/common/test_parse_args.py @@ -647,6 +647,7 @@ def setUp(self): "--pacemaker", "--promoted", "--safe", + "--show-secrets", "--simulate", "--skip-offline", "--start", diff --git a/typos.toml b/typos.toml index b1faefb47..0cbf3236b 100644 --- a/typos.toml +++ b/typos.toml @@ -33,6 +33,7 @@ relevatnt = "relevant" resrource = "resource" resourcs = "resources" restarless = "restartless" +secretes = "secrets" selimited = "delimited" simualte = "simulate" sotnith = "stonith" From 76475f8ec9ba1d2053f4d31144e274858c3da878 Mon Sep 17 00:00:00 2001 From: Miroslav Lisik Date: Wed, 13 May 2026 16:43:36 +0200 Subject: [PATCH 2/2] extract shared modifier option sets for InputModifiers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, InputModifiers.__init__ listed each option individually and the test duplicated these lists, causing them to drift apart — 12 options were missing from tests. Extract MODIFIER_OPTIONS_BOOL and MODIFIER_OPTIONS_VAL frozensets as a single source of truth, used by both the implementation and the tests. Assisted-by: Claude Code (Claude Opus 4.6) --- pcs/cli/common/parse_args.py | 138 ++++++++++--------- pcs_test/tier0/cli/common/test_parse_args.py | 54 +------- 2 files changed, 81 insertions(+), 111 deletions(-) diff --git a/pcs/cli/common/parse_args.py b/pcs/cli/common/parse_args.py index 5221c3afb..bc9389fd2 100644 --- a/pcs/cli/common/parse_args.py +++ b/pcs/cli/common/parse_args.py @@ -44,6 +44,75 @@ ) ) +MODIFIER_OPTIONS_BOOL: Final[frozenset[str]] = frozenset( + ( + "--all", + "--agent-validation", + # TODO remove + # used only in acl commands and it is deprecated there + "--autodelete", + "--brief", + "--config", + "--corosync", + "--debug", + "--defaults", + "--disabled", + "--enable", + "--expired", + "--force", + "--full", + "--quiet", + FUTURE_OPTION, + # TODO remove + # used only in deprecated 'pcs resource|stonith show' + "--groups", + "--hide-inactive", + "--local", + "--monitor", + "--no-default-ops", + "--nodesc", + "--no-expire-check", + "--no-cluster-uuid", + "--no-keys-sync", + "--no-stop", + "--no-strict", + "--no-watchdog-validation", + "--off", + "--overwrite", + "--pacemaker", + "--promoted", + "--safe", + "--show-secrets", + "--simulate", + "--skip-offline", + "--start", + "--strict", + "--yes", + ) +) + +MODIFIER_OPTIONS_VAL: Final[frozenset[str]] = frozenset( + ( + "--after", + "--before", + "--booth-conf", + "--booth-key", + "--corosync_conf", + "--from", + # TODO remove + # used in resource create and stonith create, deprecated in both + "--group", + "--name", + "--node", + "--request-timeout", + "--to", + "--token", + "-f", + "-p", + "-u", + ) +) + ARG_TYPE_DELIMITER: Final = "%" # h = help, f = file, @@ -526,75 +595,18 @@ class InputModifiers: def __init__(self, options: Mapping[str, ModifierValueType]): self._defined_options = set(options.keys()) self._options = dict(options) + self._options.update( + {opt: opt in options for opt in MODIFIER_OPTIONS_BOOL} + ) + self._options.update( + {opt: options.get(opt, None) for opt in MODIFIER_OPTIONS_VAL} + ) self._options.update( { - # boolean values - "--all": "--all" in options, - "--agent-validation": "--agent-validation" in options, - # TODO remove - # used only in acl commands and it is deprecated there - "--autodelete": "--autodelete" in options, - "--brief": "--brief" in options, - "--config": "--config" in options, - "--corosync": "--corosync" in options, - "--debug": "--debug" in options, - "--defaults": "--defaults" in options, - "--disabled": "--disabled" in options, - "--enable": "--enable" in options, - "--expired": "--expired" in options, - "--force": "--force" in options, - "--full": "--full" in options, - "--quiet": "--quiet" in options, - FUTURE_OPTION: FUTURE_OPTION in options, - # TODO remove - # used only in deprecated 'pcs resource|stonith show' - "--groups": "--groups" in options, - "--hide-inactive": "--hide-inactive" in options, - "--local": "--local" in options, - "--monitor": "--monitor" in options, - "--no-default-ops": "--no-default-ops" in options, - "--nodesc": "--nodesc" in options, - "--no-expire-check": "--no-expire-check" in options, - "--no-cluster-uuid": "--no-cluster-uuid" in options, - "--no-keys-sync": "--no-keys-sync" in options, - "--no-stop": "--no-stop" in options, - "--no-strict": "--no-strict" in options, - "--no-watchdog-validation": ( - "--no-watchdog-validation" in options - ), - "--off": "--off" in options, - "--overwrite": "--overwrite" in options, - "--pacemaker": "--pacemaker" in options, - "--promoted": "--promoted" in options, - "--safe": "--safe" in options, - "--show-secrets": "--show-secrets" in options, - "--simulate": "--simulate" in options, - "--skip-offline": "--skip-offline" in options, - "--start": "--start" in options, - "--strict": "--strict" in options, - "--yes": "--yes" in options, - # string values - "--after": options.get("--after", None), - "--before": options.get("--before", None), - "--booth-conf": options.get("--booth-conf", None), - "--booth-key": options.get("--booth-key", None), - "--corosync_conf": options.get("--corosync_conf", None), - "--from": options.get("--from", None), - # TODO remove - # used in resource create and stonith create, deprecated in both - "--group": options.get("--group", None), - "--name": options.get("--name", None), - "--node": options.get("--node", None), OUTPUT_FORMAT_OPTION: options.get( OUTPUT_FORMAT_OPTION, OUTPUT_FORMAT_VALUE_TEXT ), - "--request-timeout": options.get("--request-timeout", None), - "--to": options.get("--to", None), - "--token": options.get("--token", None), "--wait": options.get("--wait", False), - "-f": options.get("-f", None), - "-p": options.get("-p", None), - "-u": options.get("-u", None), } ) diff --git a/pcs_test/tier0/cli/common/test_parse_args.py b/pcs_test/tier0/cli/common/test_parse_args.py index 747a69dfb..9641734fc 100644 --- a/pcs_test/tier0/cli/common/test_parse_args.py +++ b/pcs_test/tier0/cli/common/test_parse_args.py @@ -2,6 +2,8 @@ from pcs.cli.common.errors import CmdLineInputError from pcs.cli.common.parse_args import ( + MODIFIER_OPTIONS_BOOL, + MODIFIER_OPTIONS_VAL, ArgsByKeywords, InputModifiers, KeyValueParser, @@ -621,54 +623,10 @@ class InputModifiersTest(TestCase): # pylint: disable=too-many-public-methods def setUp(self): self.supported = ["a", "b", "c"] - self.bool_opts = [ - "--all", - "--autodelete", - "--config", - "--corosync", - "--debug", - "--defaults", - "--disabled", - "--enable", - "--force", - "--full", - # TODO remove - # used only in deprecated 'pcs resource|stonith show' - "--groups", - "--hide-inactive", - "--local", - "--monitor", - "--no-default-ops", - "--no-expire-check", - "--no-strict", - "--no-watchdog-validation", - "--nodesc", - "--off", - "--pacemaker", - "--promoted", - "--safe", - "--show-secrets", - "--simulate", - "--skip-offline", - "--start", - ] - self.val_opts = [ - "--after", - "--before", - "--booth-conf", - "--booth-key", - "--corosync_conf", - "--from", - "--group", - "--name", - "--node", - "--request-timeout", - "--to", - # "--wait", # --wait is a special case, it has its own tests - "-f", - "-p", - "-u", - ] + # --debug is implicitly supported in all commands, tested separately + # in test_debug_implicit + self.bool_opts = sorted(MODIFIER_OPTIONS_BOOL - {"--debug"}) + self.val_opts = sorted(MODIFIER_OPTIONS_VAL) def _get_specified(self, *keys): # pylint: disable=no-self-use