-
Notifications
You must be signed in to change notification settings - Fork 3k
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
{Core} Build and use command index #13294
Merged
+424
−54
Merged
Changes from 8 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
dd03e8f
Build and use command index
jiasli 629c3a5
Invalidate command index
jiasli 587825a
invalidate_command_index when switching profiles
jiasli fa8c020
Merge branch 'dev' into performance
jiasli 195dcbc
Refine debug log
jiasli 09d850f
Add test for extending group
jiasli 6c7b97b
Fix linter
jiasli 9bf72d1
Detect index version mismatch
jiasli f1915fc
Invalidate command index for cloud profile change
jiasli 8defa9f
Extract class CommandIndex
jiasli cdff038
Pass cli_ctx conditionally
jiasli f3747e2
Sort classes
jiasli 1b3b033
Doc
jiasli 0c02c0b
Add use_command_index config
jiasli 5c52141
Patch test_command_index
jiasli 3d9261a
Enable by default
jiasli 4157378
Add comments
jiasli 32108ad
Count more accurately
jiasli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ | |
import requests | ||
from pkg_resources import parse_version | ||
|
||
from azure.cli.core import invalidate_command_index | ||
from azure.cli.core.util import CLIError, reload_module | ||
from azure.cli.core.extension import (extension_exists, build_extension_path, get_extensions, get_extension_modname, | ||
get_extension, ext_compat_with_cli, | ||
|
@@ -188,8 +189,8 @@ def _augment_telemetry_with_ext_info(extension_name, ext=None): | |
|
||
def check_version_compatibility(azext_metadata): | ||
is_compatible, cli_core_version, min_required, max_required = ext_compat_with_cli(azext_metadata) | ||
logger.debug("Extension compatibility result: is_compatible=%s cli_core_version=%s min_required=%s " | ||
"max_required=%s", is_compatible, cli_core_version, min_required, max_required) | ||
# logger.debug("Extension compatibility result: is_compatible=%s cli_core_version=%s min_required=%s " | ||
# "max_required=%s", is_compatible, cli_core_version, min_required, max_required) | ||
if not is_compatible: | ||
min_max_msg_fmt = "The '{}' extension is not compatible with this version of the CLI.\n" \ | ||
"You have CLI core version {} and this extension " \ | ||
|
@@ -234,6 +235,7 @@ def add_extension(cmd, source=None, extension_name=None, index_url=None, yes=Non | |
"Please use with discretion.", extension_name) | ||
elif extension_name and ext.preview: | ||
logger.warning("The installed extension '%s' is in preview.", extension_name) | ||
invalidate_command_index() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @haroldrandom Please help verify this is the correct location to invalidate command index after changing extensions. |
||
except ExtensionNotInstalledException: | ||
pass | ||
|
||
|
@@ -253,6 +255,7 @@ def log_err(func, path, exc_info): | |
# We call this just before we remove the extension so we can get the metadata before it is gone | ||
_augment_telemetry_with_ext_info(extension_name, ext) | ||
shutil.rmtree(ext.path, onerror=log_err) | ||
invalidate_command_index() | ||
except ExtensionNotInstalledException as e: | ||
raise CLIError(e) | ||
|
||
|
@@ -305,6 +308,7 @@ def update_extension(cmd, extension_name, index_url=None, pip_extra_index_urls=N | |
logger.debug('Copying %s to %s', backup_dir, extension_path) | ||
shutil.copytree(backup_dir, extension_path) | ||
raise CLIError('Failed to update. Rolled {} back to {}.'.format(extension_name, cur_version)) | ||
invalidate_command_index() | ||
except ExtensionNotInstalledException as e: | ||
raise CLIError(e) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disabling this log as it corrupts the new extension loading table.