Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collections fix, always mount the doc cache #1062

Merged
merged 6 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/changelog-fragments.d/1062.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Prevented issues rendering collection plugin details after errors
were generated when applying settings from within the TUI.

-- by {user}`cidrblock`
13 changes: 13 additions & 0 deletions src/ansible_navigator/actions/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,22 @@ def run(self, interaction: Interaction, app: AppPublic) -> Optional[Interaction]
)

self._update_args(params=params, attach_cdc=True)

self._collection_cache = self._args.internals.collection_doc_cache
self._collection_cache_path = self._args.collection_doc_cache_path

if not isinstance(self._collection_cache, KeyValueStore):
notification = warning_notification(
messages=[
"Something has gone really wrong, the collection document cache is not",
"available. This should not have happened. Please log an issue, and",
"include the contents of the log file.",
],
)
interaction.ui.show(notification)
self._prepare_to_exit(interaction)
return None

self._run_runner()

if not self._collections:
Expand Down
12 changes: 7 additions & 5 deletions src/ansible_navigator/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,10 @@ def parse_and_update(
apply_previous_cli_entries: Union[C, List[str]] = C.NONE,
attach_cdc=False,
) -> Tuple[List[LogMessage], List[ExitMessage]]:
"""Build a configuration
"""Build a configuration.
Return after the CDC is mounted, even if exit messages are generated, the CDC may still
be needed. e.g. ``:collections --ee NotBool``.
:param args: The application args
:param apply_previous_cli_entries: Should previous params from the CLI be applied
Expand Down Expand Up @@ -170,8 +173,6 @@ def parse_and_update(
new_messages, new_exit_messages = configurator.configure()
messages.extend(new_messages)
exit_messages.extend(new_exit_messages)
if exit_messages:
return messages, exit_messages

if args.internals.collection_doc_cache is C.NOT_SET:
mount_collection_cache = True
Expand All @@ -184,13 +185,14 @@ def parse_and_update(
else:
mount_collection_cache = False

if mount_collection_cache:
if mount_collection_cache and isinstance(args.collection_doc_cache_path, str):
new_messages, new_exit_messages, cache = get_and_check_collection_doc_cache(
args.collection_doc_cache_path,
)
messages.extend(new_messages)
exit_messages.extend(new_exit_messages)
if exit_messages or cache is None:
if cache is None:
# There's nothing to be done here, it cannot be attached.
return messages, exit_messages
if attach_cdc:
args.internals.collection_doc_cache = cache
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "test[1-:0-Browse company_name.coll_1 plugins window]",
"index": 1,
"comment": "Browse company_name.coll_1 plugins window",
"output": [
" COMPANY NAME.COLL 1 TYPE ADDED DEPRECATED DESCRIPTION",
"0│lookup_1 lookup 1.0.0 False This is test lookup plugin",
"1│mod_1 module 1.0.0 False This is a test module",
"^f/PgUp page up ^b/PgDn page down ↑↓ scroll esc back [0-9] goto :help help"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "test[2-:0-lookup_1 plugin docs window]",
"index": 2,
"comment": "lookup_1 plugin docs window",
"output": [
"COMPANY_NAME.COLL_1.LOOKUP_1: This is test lookup plugin",
" 0│---",
" 1│additional_information: {}",
" 2│collection_info:",
" 3│ authors:",
" 4│ - Ansible team (ansible-navigator)",
" 5│ license_file: LICENSE",
" 6│ name: company_name.coll_1",
" 7│ namespace: company_name",
" 8│ path: /tmp/collections_to_volmount/ansible_collections/company_name/coll_1",
" 9│ readme: README.md",
"10│ shadowed_by: []",
"11│ version: 1.0.0",
"12│doc:",
"13│ author: test",
"14│ description:",
"15│ - This is test lookup plugin",
"16│ name: lookup_1",
"17│ notes:",
"18│ - This is a dummy lookup plugin",
"19│ options:",
"20│ bar:",
"21│ default: candidate",
"22│ description:",
"23│ - Dummy option I(bar)",
"24│ type: str",
"25│ foo:",
"26│ description:",
"27│ - Dummy option I(foo)",
"28│ required: true",
"29│ type: str",
"30│ plugin_type: lookup",
"31│ short_description: This is test lookup plugin",
"32│ version_added: 1.0.0",
"33│ version_added_collection: company_name.coll_1",
"34│examples: |-",
"35│ - name: Retrieve a value deep inside a using a path",
"36│ ansible.builtin.set_fact:",
"37│ value: \"{{ lookup('company_name.coll_1.lookup_1', var1, var2) }}\"",
"38│full_name: company_name.coll_1.lookup_1",
"39│metadata: null",
"40│returndocs:",
"41│ _raw:",
"42│ description:",
"43│ - One or more zero-based indices of the matching list items.",
"^f/PgUp page up ^b/PgDn page down ↑↓ scroll esc back - previous + next [0-9] goto :help help"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

testdata = [
(0, CLI, "ansible-navigator collections browse window"),
(1, ":0", "Browse company_name.coll_1 plugins window"),
(2, ":0", "lookup_1 plugin docs window"),
]


Expand Down