diff --git a/docs/_ext/single_sourced_data.py b/docs/_ext/single_sourced_data.py index 2f81189af..945756288 100644 --- a/docs/_ext/single_sourced_data.py +++ b/docs/_ext/single_sourced_data.py @@ -22,7 +22,7 @@ from ansible_navigator import __version__ from ansible_navigator.configuration_subsystem import NavigatorConfiguration from ansible_navigator.configuration_subsystem import Constants as C -from ansible_navigator.configuration_subsystem.definitions import Entry +from ansible_navigator.configuration_subsystem.definitions import SettingsEntry from ansible_navigator.utils import oxfordcomma @@ -162,7 +162,7 @@ def _params_retrieve_details(filename: str) -> Dict: return yaml.load(fhand, Loader=yaml.SafeLoader) -def _params_row_for_entry(entry: Entry, param_details: Dict) -> Tuple: +def _params_row_for_entry(entry: SettingsEntry, param_details: Dict) -> Tuple: # pylint: disable=too-many-branches """create a row entry for a param""" if entry.cli_parameters is None: diff --git a/src/ansible_navigator/configuration_subsystem/__init__.py b/src/ansible_navigator/configuration_subsystem/__init__.py index 81be33072..75f86a4e5 100644 --- a/src/ansible_navigator/configuration_subsystem/__init__.py +++ b/src/ansible_navigator/configuration_subsystem/__init__.py @@ -3,5 +3,5 @@ from .configurator import Configurator from .definitions import ApplicationConfiguration from .definitions import Constants -from .definitions import Entry +from .definitions import SettingsEntry from .navigator_configuration import NavigatorConfiguration diff --git a/src/ansible_navigator/configuration_subsystem/definitions.py b/src/ansible_navigator/configuration_subsystem/definitions.py index 6f1209d1a..4d74c6be6 100644 --- a/src/ansible_navigator/configuration_subsystem/definitions.py +++ b/src/ansible_navigator/configuration_subsystem/definitions.py @@ -44,7 +44,7 @@ class Constants(Enum): USER_CLI = "cli parameters" -class EntryValue(SimpleNamespace): +class SettingsEntryValue(SimpleNamespace): # pylint: disable=too-few-public-methods """An object to store a value""" @@ -53,7 +53,7 @@ class EntryValue(SimpleNamespace): source: Constants = Constants.NOT_SET -class Entry(SimpleNamespace): +class SettingsEntry(SimpleNamespace): # pylint: disable=too-few-public-methods """One entry in the configuration @@ -67,11 +67,11 @@ class Entry(SimpleNamespace): short_description: A short description used for the argparse help subcommand_value: Does the hold the names of the subcommand subcommands: which subcommand should this be used for - value: the EntryValue for the entry + value: the SettingsEntryValue for the entry """ name: str short_description: str - value: EntryValue + value: SettingsEntryValue apply_to_subsequent_cli: Constants = Constants.ALL change_after_initial: bool = True @@ -134,7 +134,7 @@ class ApplicationConfiguration(SimpleNamespace): """The main object for storing an application config""" application_name: str = "" - entries: List[Entry] = [] + entries: List[SettingsEntry] = [] internals: SimpleNamespace subcommands: List[SubCommand] post_processor = Callable @@ -154,7 +154,7 @@ def __getattribute__(self, attr: str) -> Any: except KeyError: return super().__getattribute__(attr) - def entry(self, name) -> Entry: + def entry(self, name) -> SettingsEntry: """Retrieve a configuration entry by name""" return self._get_by_name(name, "entries") diff --git a/src/ansible_navigator/configuration_subsystem/navigator_configuration.py b/src/ansible_navigator/configuration_subsystem/navigator_configuration.py index 8b242cb11..6aea638f0 100644 --- a/src/ansible_navigator/configuration_subsystem/navigator_configuration.py +++ b/src/ansible_navigator/configuration_subsystem/navigator_configuration.py @@ -12,8 +12,8 @@ from .definitions import ApplicationConfiguration from .definitions import CliParameters from .definitions import Constants as C -from .definitions import Entry -from .definitions import EntryValue +from .definitions import SettingsEntry +from .definitions import SettingsEntryValue from .definitions import SubCommand from .navigator_post_processor import NavigatorPostProcessor @@ -161,77 +161,77 @@ class Internals(SimpleNamespace): post_processor=NavigatorPostProcessor(), subcommands=navigator_subcommds, entries=[ - Entry( + SettingsEntry( name="ansible_runner_artifact_dir", cli_parameters=CliParameters(short="--rad"), settings_file_path_override="ansible-runner.artifact-dir", short_description="The directory path to store artifacts generated by ansible-runner", - value=EntryValue(), + value=SettingsEntryValue(), ), - Entry( + SettingsEntry( name="ansible_runner_rotate_artifacts_count", cli_parameters=CliParameters(short="--rac"), settings_file_path_override="ansible-runner.rotate-artifacts-count", short_description="Keep ansible-runner artifact directories, " "for last n runs, if set to 0 artifact directories " "won't be deleted", - value=EntryValue(), + value=SettingsEntryValue(), ), - Entry( + SettingsEntry( name="ansible_runner_timeout", cli_parameters=CliParameters(short="--rt"), settings_file_path_override="ansible-runner.timeout", short_description="The timeout value after which ansible-runner will" "force stop the execution", - value=EntryValue(), + value=SettingsEntryValue(), ), - Entry( + SettingsEntry( name="app", apply_to_subsequent_cli=C.NONE, choices=[subcommand.name for subcommand in navigator_subcommds], short_description="Subcommands", subcommand_value=True, - value=EntryValue(default="welcome"), + value=SettingsEntryValue(default="welcome"), ), - Entry( + SettingsEntry( name="cmdline", apply_to_subsequent_cli=C.SAME_SUBCOMMAND, settings_file_path_override="ansible.cmdline", short_description="Extra parameters passed to the corresponding command", - value=EntryValue(), + value=SettingsEntryValue(), ), - Entry( + SettingsEntry( name="collection_doc_cache_path", cli_parameters=CliParameters(short="--cdcp"), short_description="The path to collection doc cache", - value=EntryValue(default=generate_cache_path()), + value=SettingsEntryValue(default=generate_cache_path()), ), - Entry( + SettingsEntry( name="config", cli_parameters=CliParameters(short="-c", metavar="CONFIG_FILE"), environment_variable_override="ansible_config", settings_file_path_override="ansible.config", short_description="Specify the path to the ansible configuration file", subcommands=["config"], - value=EntryValue(), + value=SettingsEntryValue(), ), - Entry( + SettingsEntry( name="container_engine", choices=["auto", "podman", "docker"], cli_parameters=CliParameters(short="--ce"), settings_file_path_override="execution-environment.container-engine", short_description="Specify the container engine (auto=podman then docker)", - value=EntryValue(default="auto"), + value=SettingsEntryValue(default="auto"), ), - Entry( + SettingsEntry( name="container_options", cli_parameters=CliParameters(action="append", nargs="+", short="--co"), environment_variable_override="ansible_navigator_container_options", settings_file_path_override="execution-environment.container-options", short_description="Extra parameters passed to the container engine command", - value=EntryValue(), + value=SettingsEntryValue(), ), - Entry( + SettingsEntry( name="display_color", change_after_initial=False, choices=[True, False], @@ -239,56 +239,56 @@ class Internals(SimpleNamespace): environment_variable_override="no_color", settings_file_path_override="color.enable", short_description="Enable the use of color in the display", - value=EntryValue(default=True), + value=SettingsEntryValue(default=True), ), - Entry( + SettingsEntry( name="editor_command", cli_parameters=CliParameters(short="--ecmd"), settings_file_path_override="editor.command", short_description="Specify the editor command", - value=EntryValue(default=generate_editor_command()), + value=SettingsEntryValue(default=generate_editor_command()), ), - Entry( + SettingsEntry( name="editor_console", choices=[True, False], cli_parameters=CliParameters(short="--econ"), settings_file_path_override="editor.console", short_description="Specify if the editor is console based", - value=EntryValue(default=True), + value=SettingsEntryValue(default=True), ), - Entry( + SettingsEntry( name="exec_command", cli_parameters=CliParameters(short="--excmd"), settings_file_path_override="exec.command", short_description="Specify the command to run within the execution environment", subcommands=["exec"], - value=EntryValue(default="/bin/bash"), + value=SettingsEntryValue(default="/bin/bash"), ), - Entry( + SettingsEntry( name="exec_shell", choices=[True, False], cli_parameters=CliParameters(short="--exshell"), settings_file_path_override="exec.shell", short_description="Specify the exec command should be run in a shell.", subcommands=["exec"], - value=EntryValue(default=True), + value=SettingsEntryValue(default=True), ), - Entry( + SettingsEntry( name="execution_environment", choices=[True, False], cli_parameters=CliParameters(short="--ee"), settings_file_path_override="execution-environment.enabled", short_description="Enable or disable the use of an execution environment", - value=EntryValue(default=True), + value=SettingsEntryValue(default=True), ), - Entry( + SettingsEntry( name="execution_environment_image", cli_parameters=CliParameters(short="--eei"), settings_file_path_override="execution-environment.image", short_description="Specify the name of the execution environment image", - value=EntryValue(default="quay.io/ansible/creator-ee:v0.2.0"), + value=SettingsEntryValue(default="quay.io/ansible/creator-ee:v0.2.0"), ), - Entry( + SettingsEntry( name="execution_environment_volume_mounts", cli_parameters=CliParameters(action="append", nargs="+", short="--eev"), delay_post_process=True, @@ -297,59 +297,59 @@ class Internals(SimpleNamespace): "Specify volume to be bind mounted within an execution environment" " (--eev /home/user/test:/home/user/test:Z)" ), - value=EntryValue(), + value=SettingsEntryValue(), ), - Entry( + SettingsEntry( name="help_config", choices=[True, False], cli_parameters=CliParameters(short="--hc", action="store_true"), short_description="Help options for ansible-config command in stdout mode", subcommands=["config"], - value=EntryValue(default=False), + value=SettingsEntryValue(default=False), ), - Entry( + SettingsEntry( name="help_doc", choices=[True, False], cli_parameters=CliParameters(short="--hd", action="store_true"), short_description="Help options for ansible-doc command in stdout mode", subcommands=["doc"], - value=EntryValue(default=False), + value=SettingsEntryValue(default=False), ), - Entry( + SettingsEntry( name="help_inventory", choices=[True, False], cli_parameters=CliParameters(short="--hi", action="store_true"), short_description="Help options for ansible-inventory command in stdout mode", subcommands=["inventory"], - value=EntryValue(default=False), + value=SettingsEntryValue(default=False), ), - Entry( + SettingsEntry( name="help_playbook", choices=[True, False], cli_parameters=CliParameters(short="--hp", action="store_true"), short_description="Help options for ansible-playbook command in stdout mode", subcommands=["run"], - value=EntryValue(default=False), + value=SettingsEntryValue(default=False), ), - Entry( + SettingsEntry( name="inventory", cli_parameters=CliParameters(action="append", nargs="+", short="-i"), environment_variable_override="ansible_navigator_inventories", settings_file_path_override="ansible.inventories", short_description="Specify an inventory file path or comma separated host list", subcommands=["inventory", "run"], - value=EntryValue(), + value=SettingsEntryValue(), ), - Entry( + SettingsEntry( name="inventory_column", cli_parameters=CliParameters(action="append", nargs="+", short="--ic"), environment_variable_override="ansible_navigator_inventory_columns", settings_file_path_override="inventory-columns", short_description="Specify a host attribute to show in the inventory view", subcommands=["inventory", "run"], - value=EntryValue(), + value=SettingsEntryValue(), ), - Entry( + SettingsEntry( name="log_append", choices=[True, False], cli_parameters=CliParameters(short="--la"), @@ -358,40 +358,40 @@ class Internals(SimpleNamespace): " otherwise a new log file will be created per session" ), settings_file_path_override="logging.append", - value=EntryValue(default=True), + value=SettingsEntryValue(default=True), ), - Entry( + SettingsEntry( name="log_file", cli_parameters=CliParameters(short="--lf"), short_description="Specify the full path for the ansible-navigator log file", settings_file_path_override="logging.file", - value=EntryValue(default=abs_user_path("./ansible-navigator.log")), + value=SettingsEntryValue(default=abs_user_path("./ansible-navigator.log")), ), - Entry( + SettingsEntry( name="log_level", choices=["debug", "info", "warning", "error", "critical"], cli_parameters=CliParameters(short="--ll"), short_description="Specify the ansible-navigator log level", settings_file_path_override="logging.level", - value=EntryValue(default="warning"), + value=SettingsEntryValue(default="warning"), ), - Entry( + SettingsEntry( name="mode", change_after_initial=False, choices=["stdout", "interactive"], cli_parameters=CliParameters(short="-m"), short_description="Specify the user-interface mode", - value=EntryValue(default="interactive"), + value=SettingsEntryValue(default="interactive"), ), - Entry( + SettingsEntry( name="osc4", choices=[True, False], cli_parameters=CliParameters(short="--osc4"), settings_file_path_override="color.osc4", short_description="Enable or disable terminal color changing support with OSC 4", - value=EntryValue(default=True), + value=SettingsEntryValue(default=True), ), - Entry( + SettingsEntry( name="pass_environment_variable", cli_parameters=CliParameters(action="append", nargs="+", short="--penv"), environment_variable_override="ansible_navigator_pass_environment_variables", @@ -400,17 +400,17 @@ class Internals(SimpleNamespace): "Specify an exiting environment variable to be passed through" " to and set within the execution environment (--penv MY_VAR)" ), - value=EntryValue(), + value=SettingsEntryValue(), ), - Entry( + SettingsEntry( name="playbook", cli_parameters=CliParameters(positional=True), short_description="Specify the playbook name", settings_file_path_override="ansible.playbook", subcommands=["run"], - value=EntryValue(), + value=SettingsEntryValue(), ), - Entry( + SettingsEntry( name="playbook_artifact_enable", choices=[True, False], cli_parameters=CliParameters(short="--pae"), @@ -419,42 +419,44 @@ class Internals(SimpleNamespace): " completed playbooks. Note: not compatible with '--mode stdout' when playbooks" " require user input", subcommands=["run"], - value=EntryValue(default=True), + value=SettingsEntryValue(default=True), ), - Entry( + SettingsEntry( name="playbook_artifact_replay", cli_parameters=CliParameters(positional=True), settings_file_path_override="playbook-artifact.replay", short_description="Specify the path for the playbook artifact to replay", subcommands=["replay"], - value=EntryValue(), + value=SettingsEntryValue(), ), - Entry( + SettingsEntry( name="playbook_artifact_save_as", cli_parameters=CliParameters(short="--pas"), settings_file_path_override="playbook-artifact.save-as", short_description="Specify the name for artifacts created from completed playbooks", subcommands=["run"], - value=EntryValue(default="{playbook_dir}/{playbook_name}-artifact-{ts_utc}.json"), + value=SettingsEntryValue( + default="{playbook_dir}/{playbook_name}-artifact-{ts_utc}.json" + ), ), - Entry( + SettingsEntry( name="plugin_name", cli_parameters=CliParameters(positional=True), settings_file_path_override="documentation.plugin.name", short_description="Specify the plugin name", subcommands=["doc"], - value=EntryValue(), + value=SettingsEntryValue(), ), - Entry( + SettingsEntry( name="plugin_type", choices=PLUGIN_TYPES, cli_parameters=CliParameters(short="-t", long_override="--type"), settings_file_path_override="documentation.plugin.type", short_description=f"Specify the plugin type, {oxfordcomma(PLUGIN_TYPES, 'or')}", subcommands=["doc"], - value=EntryValue(default="module"), + value=SettingsEntryValue(default="module"), ), - Entry( + SettingsEntry( name="pull_policy", choices=["always", "missing", "never", "tag"], cli_parameters=CliParameters(short="--pp"), @@ -467,9 +469,9 @@ class Internals(SimpleNamespace): " tag:if the image tag is 'latest', always pull the image," " otherwise pull if not locally available" ), - value=EntryValue(default="tag"), + value=SettingsEntryValue(default="tag"), ), - Entry( + SettingsEntry( name="set_environment_variable", cli_parameters=CliParameters(action="append", nargs="+", short="--senv"), environment_variable_override="ansible_navigator_set_environment_variables", @@ -478,7 +480,7 @@ class Internals(SimpleNamespace): "Specify an environment variable and a value to be set within the" " execution environment (--senv MY_VAR=42)" ), - value=EntryValue(), + value=SettingsEntryValue(), ), ], ) diff --git a/src/ansible_navigator/configuration_subsystem/navigator_post_processor.py b/src/ansible_navigator/configuration_subsystem/navigator_post_processor.py index 31a784c0b..5810c4656 100644 --- a/src/ansible_navigator/configuration_subsystem/navigator_post_processor.py +++ b/src/ansible_navigator/configuration_subsystem/navigator_post_processor.py @@ -12,8 +12,9 @@ from typing import List from typing import Tuple +from .definitions import CliParameters from .definitions import Constants as C -from .definitions import Entry +from .definitions import SettingsEntry from .definitions import ApplicationConfiguration from ..utils import abs_user_path @@ -107,7 +108,9 @@ def __init__(self): self.extra_volume_mounts: List[VolumeMount] = [] @staticmethod - def _true_or_false(entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def _true_or_false( + entry: SettingsEntry, config: ApplicationConfiguration + ) -> PostProcessorReturn: # pylint: disable=unused-argument messages: List[LogMessage] = [] exit_messages: List[ExitMessage] = [] @@ -122,7 +125,7 @@ def _true_or_false(entry: Entry, config: ApplicationConfiguration) -> PostProces @staticmethod @_post_processor def ansible_runner_artifact_dir( - entry: Entry, config: ApplicationConfiguration + entry: SettingsEntry, config: ApplicationConfiguration ) -> PostProcessorReturn: # pylint: disable=unused-argument """Post process ansible_runner_artifact_dir path""" @@ -135,7 +138,7 @@ def ansible_runner_artifact_dir( @staticmethod @_post_processor def ansible_runner_rotate_artifacts_count( - entry: Entry, config: ApplicationConfiguration + entry: SettingsEntry, config: ApplicationConfiguration ) -> PostProcessorReturn: # pylint: disable=unused-argument """Post process ansible_runner_rotate_artifacts_count""" @@ -152,7 +155,7 @@ def ansible_runner_rotate_artifacts_count( @staticmethod @_post_processor def ansible_runner_timeout( - entry: Entry, config: ApplicationConfiguration + entry: SettingsEntry, config: ApplicationConfiguration ) -> PostProcessorReturn: # pylint: disable=unused-argument """Post process ansible_runner_timeout""" @@ -169,7 +172,7 @@ def ansible_runner_timeout( @staticmethod @_post_processor def collection_doc_cache_path( - entry: Entry, config: ApplicationConfiguration + entry: SettingsEntry, config: ApplicationConfiguration ) -> PostProcessorReturn: # pylint: disable=unused-argument """Post process collection doc cache path""" @@ -180,7 +183,7 @@ def collection_doc_cache_path( @staticmethod @_post_processor - def cmdline(entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def cmdline(entry: SettingsEntry, config: ApplicationConfiguration) -> PostProcessorReturn: # pylint: disable=unused-argument """Post process cmdline""" messages: List[LogMessage] = [] @@ -191,7 +194,9 @@ def cmdline(entry: Entry, config: ApplicationConfiguration) -> PostProcessorRetu @staticmethod @_post_processor - def container_engine(entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def container_engine( + entry: SettingsEntry, config: ApplicationConfiguration + ) -> PostProcessorReturn: # pylint: disable=unused-argument """Post process container_engine""" messages: List[LogMessage] = [] @@ -205,7 +210,9 @@ def container_engine(entry: Entry, config: ApplicationConfiguration) -> PostProc return messages, exit_messages @_post_processor - def display_color(self, entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def display_color( + self, entry: SettingsEntry, config: ApplicationConfiguration + ) -> PostProcessorReturn: """Post process displacy_color""" messages: List[LogMessage] = [] exit_messages: List[ExitMessage] = [] @@ -217,12 +224,15 @@ def display_color(self, entry: Entry, config: ApplicationConfiguration) -> PostP return self._true_or_false(entry, config) @_post_processor - def editor_console(self, entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def editor_console( + self, entry: SettingsEntry, config: ApplicationConfiguration + ) -> PostProcessorReturn: """Post process editor_console""" return self._true_or_false(entry, config) @_post_processor - def execution_environment(self, entry, config) -> PostProcessorReturn: + def execution_environment(self, entry: SettingsEntry, config) -> PostProcessorReturn: + # pylint: disable=too-many-branches # pylint: disable=too-many-locals """Post process execution_environment""" messages, exit_messages = self._true_or_false(entry, config) @@ -239,7 +249,10 @@ def execution_environment(self, entry, config) -> PostProcessorReturn: exit_msg += f" set by '{config.entry('container_engine').value.source.value}'" exit_messages.append(ExitMessage(message=exit_msg)) ce_short = config.entry("container_engine").cli_parameters.short - entry_short = entry.cli_parameters.short + if isinstance(entry.cli_parameters, CliParameters): + entry_short = entry.cli_parameters.short + else: + entry_short = None choices = config.entry("container_engine").choices if ce_short and entry_short: hint = "" @@ -262,7 +275,7 @@ def execution_environment(self, entry, config) -> PostProcessorReturn: messages.extend(new_messages) exit_messages.extend(new_exit_messages) - if config.app == "exec": + if config.app == "exec" and isinstance(entry.cli_parameters, CliParameters): exit_msg = "The 'exec' subcommand requires execution environment support." exit_messages.append(ExitMessage(message=exit_msg)) hint = ( @@ -276,7 +289,7 @@ def execution_environment(self, entry, config) -> PostProcessorReturn: @staticmethod @_post_processor def execution_environment_image( - entry: Entry, config: ApplicationConfiguration + entry: SettingsEntry, config: ApplicationConfiguration ) -> PostProcessorReturn: # pylint: disable=unused-argument """Post process execution_environment_image""" @@ -288,7 +301,7 @@ def execution_environment_image( @_post_processor def execution_environment_volume_mounts( - self, entry: Entry, config: ApplicationConfiguration + self, entry: SettingsEntry, config: ApplicationConfiguration ) -> PostProcessorReturn: # pylint: disable=unused-argument # pylint: disable=too-many-branches @@ -374,7 +387,9 @@ def execution_environment_volume_mounts( @staticmethod @_post_processor - def container_options(entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def container_options( + entry: SettingsEntry, config: ApplicationConfiguration + ) -> PostProcessorReturn: # pylint: disable=unused-argument """Post process container_options""" messages: List[LogMessage] = [] @@ -386,7 +401,9 @@ def container_options(entry: Entry, config: ApplicationConfiguration) -> PostPro return messages, exit_messages @_post_processor - def exec_shell(self, entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def exec_shell( + self, entry: SettingsEntry, config: ApplicationConfiguration + ) -> PostProcessorReturn: # pylint: disable=unused-argument """Post process ``exec_shell``. @@ -397,7 +414,9 @@ def exec_shell(self, entry: Entry, config: ApplicationConfiguration) -> PostProc return self._true_or_false(entry, config) @_post_processor - def help_config(self, entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def help_config( + self, entry: SettingsEntry, config: ApplicationConfiguration + ) -> PostProcessorReturn: # pylint: disable=unused-argument """Post process help_config""" messages, exit_messages = self._true_or_false(entry, config) @@ -419,7 +438,9 @@ def help_config(self, entry: Entry, config: ApplicationConfiguration) -> PostPro return messages, exit_messages @_post_processor - def help_doc(self, entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def help_doc( + self, entry: SettingsEntry, config: ApplicationConfiguration + ) -> PostProcessorReturn: # pylint: disable=unused-argument """Post process help_doc""" messages, exit_messages = self._true_or_false(entry, config) @@ -441,7 +462,9 @@ def help_doc(self, entry: Entry, config: ApplicationConfiguration) -> PostProces return messages, exit_messages @_post_processor - def help_inventory(self, entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def help_inventory( + self, entry: SettingsEntry, config: ApplicationConfiguration + ) -> PostProcessorReturn: # pylint: disable=unused-argument """Post process help_inventory""" messages, exit_messages = self._true_or_false(entry, config) @@ -465,7 +488,9 @@ def help_inventory(self, entry: Entry, config: ApplicationConfiguration) -> Post return messages, exit_messages @_post_processor - def help_playbook(self, entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def help_playbook( + self, entry: SettingsEntry, config: ApplicationConfiguration + ) -> PostProcessorReturn: # pylint: disable=unused-argument """Post process help_playbook""" messages, exit_messages = self._true_or_false(entry, config) @@ -488,7 +513,7 @@ def help_playbook(self, entry: Entry, config: ApplicationConfiguration) -> PostP @staticmethod @_post_processor - def inventory(entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def inventory(entry: SettingsEntry, config: ApplicationConfiguration) -> PostProcessorReturn: """Post process inventory""" messages: List[LogMessage] = [] exit_messages: List[ExitMessage] = [] @@ -517,7 +542,9 @@ def inventory(entry: Entry, config: ApplicationConfiguration) -> PostProcessorRe @staticmethod @_post_processor - def inventory_column(entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def inventory_column( + entry: SettingsEntry, config: ApplicationConfiguration + ) -> PostProcessorReturn: # pylint: disable=unused-argument """Post process inventory_columns""" messages: List[LogMessage] = [] @@ -527,13 +554,15 @@ def inventory_column(entry: Entry, config: ApplicationConfiguration) -> PostProc return messages, exit_messages @_post_processor - def log_append(self, entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def log_append( + self, entry: SettingsEntry, config: ApplicationConfiguration + ) -> PostProcessorReturn: """Post process log_append""" return self._true_or_false(entry, config) @staticmethod @_post_processor - def log_file(entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def log_file(entry: SettingsEntry, config: ApplicationConfiguration) -> PostProcessorReturn: # pylint: disable=unused-argument """Post process log_file @@ -570,7 +599,7 @@ def log_file(entry: Entry, config: ApplicationConfiguration) -> PostProcessorRet @staticmethod @_post_processor - def mode(entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def mode(entry: SettingsEntry, config: ApplicationConfiguration) -> PostProcessorReturn: # pylint: disable=too-many-statements """Post process mode""" messages: List[LogMessage] = [] @@ -642,13 +671,13 @@ def mode(entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: return messages, exit_messages @_post_processor - def osc4(self, entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def osc4(self, entry: SettingsEntry, config: ApplicationConfiguration) -> PostProcessorReturn: """Post process osc4""" return self._true_or_false(entry, config) @staticmethod @_post_processor - def plugin_name(entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def plugin_name(entry: SettingsEntry, config: ApplicationConfiguration) -> PostProcessorReturn: """Post process plugin_name""" messages: List[LogMessage] = [] exit_messages: List[ExitMessage] = [] @@ -670,7 +699,7 @@ def plugin_name(entry: Entry, config: ApplicationConfiguration) -> PostProcessor @staticmethod @_post_processor def pass_environment_variable( - entry: Entry, config: ApplicationConfiguration + entry: SettingsEntry, config: ApplicationConfiguration ) -> PostProcessorReturn: # pylint: disable=unused-argument """Post process pass_environment_variable""" @@ -682,7 +711,7 @@ def pass_environment_variable( @staticmethod @_post_processor - def playbook(entry: Entry, config: ApplicationConfiguration) -> PostProcessorReturn: + def playbook(entry: SettingsEntry, config: ApplicationConfiguration) -> PostProcessorReturn: # pylint: disable=unused-argument """Post process pass_environment_variable""" messages: List[LogMessage] = [] @@ -703,7 +732,7 @@ def playbook(entry: Entry, config: ApplicationConfiguration) -> PostProcessorRet @_post_processor def playbook_artifact_enable( - self, entry: Entry, config: ApplicationConfiguration + self, entry: SettingsEntry, config: ApplicationConfiguration ) -> PostProcessorReturn: """Post process playbook_artifact_enable""" return self._true_or_false(entry, config) @@ -711,7 +740,7 @@ def playbook_artifact_enable( @staticmethod @_post_processor def playbook_artifact_replay( - entry: Entry, config: ApplicationConfiguration + entry: SettingsEntry, config: ApplicationConfiguration ) -> PostProcessorReturn: """Post process playbook_artifact_replay""" messages: List[LogMessage] = [] @@ -740,7 +769,7 @@ def playbook_artifact_replay( @staticmethod @_post_processor def set_environment_variable( - entry: Entry, config: ApplicationConfiguration + entry: SettingsEntry, config: ApplicationConfiguration ) -> PostProcessorReturn: # pylint: disable=unused-argument """Post process set_environment_variable""" diff --git a/tests/unit/configuration_subsystem/test_mode_subcommand_action.py b/tests/unit/configuration_subsystem/test_mode_subcommand_action.py index 11eb35822..640a16b60 100644 --- a/tests/unit/configuration_subsystem/test_mode_subcommand_action.py +++ b/tests/unit/configuration_subsystem/test_mode_subcommand_action.py @@ -4,8 +4,8 @@ from ansible_navigator.configuration_subsystem.configurator import Configurator from ansible_navigator.configuration_subsystem.definitions import ApplicationConfiguration -from ansible_navigator.configuration_subsystem.definitions import Entry -from ansible_navigator.configuration_subsystem.definitions import EntryValue +from ansible_navigator.configuration_subsystem.definitions import SettingsEntry +from ansible_navigator.configuration_subsystem.definitions import SettingsEntryValue from ansible_navigator.configuration_subsystem.definitions import SubCommand from ansible_navigator.configuration_subsystem.navigator_configuration import ( @@ -30,15 +30,15 @@ def test_import_error(): SubCommand(name="subcommand1", description="subcommand1"), ], entries=[ - Entry( + SettingsEntry( name="app", short_description="test_app", - value=EntryValue(current="subcommand1"), + value=SettingsEntryValue(current="subcommand1"), ), - Entry( + SettingsEntry( name="mode", short_description="mode", - value=EntryValue(), + value=SettingsEntryValue(), ), ], ) @@ -61,15 +61,15 @@ def test_subcommand_not_found(): SubCommand(name="__test_action", description="test_action"), ], entries=[ - Entry( + SettingsEntry( name="app", short_description="test_app", - value=EntryValue(current="__test_action"), + value=SettingsEntryValue(current="__test_action"), ), - Entry( + SettingsEntry( name="mode", short_description="mode", - value=EntryValue(), + value=SettingsEntryValue(), ), ], ) diff --git a/tests/unit/configuration_subsystem/test_previous_cli.py b/tests/unit/configuration_subsystem/test_previous_cli.py index 0e04c6197..99aaf1c54 100644 --- a/tests/unit/configuration_subsystem/test_previous_cli.py +++ b/tests/unit/configuration_subsystem/test_previous_cli.py @@ -14,8 +14,8 @@ from ansible_navigator.configuration_subsystem.definitions import ApplicationConfiguration from ansible_navigator.configuration_subsystem.definitions import CliParameters from ansible_navigator.configuration_subsystem.definitions import Constants as C -from ansible_navigator.configuration_subsystem.definitions import Entry -from ansible_navigator.configuration_subsystem.definitions import EntryValue +from ansible_navigator.configuration_subsystem.definitions import SettingsEntry +from ansible_navigator.configuration_subsystem.definitions import SettingsEntryValue from ansible_navigator.configuration_subsystem.definitions import SubCommand from ansible_navigator.configuration_subsystem.navigator_configuration import NavigatorConfiguration @@ -271,18 +271,18 @@ def test_apply_cli_subset_none(): SubCommand(name="run", description="run"), ], entries=[ - Entry( + SettingsEntry( name="subcommand", short_description="Subcommands", subcommand_value=True, - value=EntryValue(default="run"), + value=SettingsEntryValue(default="run"), ), - Entry( + SettingsEntry( name="z", apply_to_subsequent_cli=C.NONE, cli_parameters=CliParameters(short="-z"), short_description="the z parameter", - value=EntryValue(), + value=SettingsEntryValue(), ), ], ) diff --git a/tests/unit/configuration_subsystem/test_sample_configurations.py b/tests/unit/configuration_subsystem/test_sample_configurations.py index af661fdea..c14fea0f2 100644 --- a/tests/unit/configuration_subsystem/test_sample_configurations.py +++ b/tests/unit/configuration_subsystem/test_sample_configurations.py @@ -12,8 +12,8 @@ from ansible_navigator.configuration_subsystem.definitions import ApplicationConfiguration from ansible_navigator.configuration_subsystem.definitions import CliParameters -from ansible_navigator.configuration_subsystem.definitions import Entry -from ansible_navigator.configuration_subsystem.definitions import EntryValue +from ansible_navigator.configuration_subsystem.definitions import SettingsEntry +from ansible_navigator.configuration_subsystem.definitions import SettingsEntryValue from ansible_navigator.configuration_subsystem.definitions import SubCommand from ansible_navigator.configuration_subsystem.parser import Parser @@ -30,10 +30,10 @@ def test_cmdline_source_not_set(): SubCommand(name="subcommand1", description="subcommand1"), ], entries=[ - Entry( + SettingsEntry( name="cmdline", short_description="cmdline", - value=EntryValue(), + value=SettingsEntryValue(), ), ], ) @@ -66,17 +66,17 @@ def test_many_subcommand(): SubCommand(name="subcommand1", description="subcommand1"), ], entries=[ - Entry( + SettingsEntry( name="sb1", short_description="Subcommands", subcommand_value=True, - value=EntryValue(default="welcome"), + value=SettingsEntryValue(default="welcome"), ), - Entry( + SettingsEntry( name="sb2", short_description="Subcommands", subcommand_value=True, - value=EntryValue(default="welcome"), + value=SettingsEntryValue(default="welcome"), ), ], ) @@ -93,16 +93,16 @@ def test_invalid_choice_not_set(): SubCommand(name="subcommand1", description="subcommand1"), ], entries=[ - Entry( + SettingsEntry( name="sb1", short_description="Subcommands", subcommand_value=True, - value=EntryValue(default="welcome"), + value=SettingsEntryValue(default="welcome"), ), - Entry( + SettingsEntry( name="e1", short_description="ex1", - value=EntryValue(), + value=SettingsEntryValue(), ), ], ) @@ -119,17 +119,17 @@ def test_cutom_nargs_for_postional(): SubCommand(name="subcommand1", description="subcommand1"), ], entries=[ - Entry( + SettingsEntry( name="sb1", short_description="Subcommands", subcommand_value=True, - value=EntryValue(default="welcome"), + value=SettingsEntryValue(default="welcome"), ), - Entry( + SettingsEntry( name="e1", cli_parameters=CliParameters(positional=True, nargs=3), short_description="ex1", - value=EntryValue(), + value=SettingsEntryValue(), subcommands=["subcommand1"], ), ], diff --git a/tests/unit/configuration_subsystem/utils.py b/tests/unit/configuration_subsystem/utils.py index dd0cfc040..e96b6f860 100644 --- a/tests/unit/configuration_subsystem/utils.py +++ b/tests/unit/configuration_subsystem/utils.py @@ -1,7 +1,7 @@ """Utility functions used by adjacent tests """ -from ansible_navigator.configuration_subsystem.definitions import Entry +from ansible_navigator.configuration_subsystem.definitions import SettingsEntry def id_for_base(val): @@ -24,7 +24,7 @@ def id_for_cli(val): def id_for_name(val): """Return an id based on entry name.""" - if isinstance(val, Entry): + if isinstance(val, SettingsEntry): return f" {val.name} " return ""