-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[Extension] Add azmirror cloud endpoint for installing extensions in air gapped clouds and support config of index url #15128
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
Changes from 5 commits
5a15e31
45993c0
c252d84
5ce9bc7
20690bd
5eb1a1f
93c24c2
75c9dd9
19d1c2f
17f0e6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,11 +19,22 @@ | |
| TRIES = 3 | ||
|
|
||
|
|
||
| def get_index_url(cli_ctx=None): | ||
| import posixpath | ||
| if cli_ctx: | ||
| url = cli_ctx.config.get('extension', 'index_url', None) | ||
| if url: | ||
| return url | ||
| ext_endpoint = cli_ctx.cloud.endpoints.extension_storage_account_resource_id if cli_ctx and \ | ||
|
Member
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. config overrides cloud setting |
||
| cli_ctx.cloud.endpoints.has_endpoint_set('extension_storage_account_resource_id') else None | ||
| return posixpath.join(ext_endpoint, 'index.json') if ext_endpoint else DEFAULT_INDEX_URL | ||
|
|
||
|
|
||
| # pylint: disable=inconsistent-return-statements | ||
| def get_index(index_url=None): | ||
| def get_index(index_url=None, cli_ctx=None): | ||
| import requests | ||
| from azure.cli.core.util import should_disable_connection_verify | ||
| index_url = index_url or DEFAULT_INDEX_URL | ||
| index_url = index_url or get_index_url(cli_ctx=cli_ctx) | ||
|
|
||
| for try_number in range(TRIES): | ||
| try: | ||
|
|
@@ -45,8 +56,8 @@ def get_index(index_url=None): | |
| continue | ||
|
|
||
|
|
||
| def get_index_extensions(index_url=None): | ||
| index = get_index(index_url=index_url) | ||
| def get_index_extensions(index_url=None, cli_ctx=None): | ||
| index = get_index(index_url=index_url, cli_ctx=cli_ctx) | ||
| extensions = index.get('extensions') | ||
| if extensions is None: | ||
| logger.warning(ERR_UNABLE_TO_GET_EXTENSIONS) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,13 +53,13 @@ def filter_func(item): | |
| return filter_func | ||
|
|
||
|
|
||
| def resolve_from_index(extension_name, cur_version=None, index_url=None, target_version=None): | ||
| def resolve_from_index(extension_name, cur_version=None, index_url=None, target_version=None, cli_ctx=None): | ||
| """ | ||
| Gets the download Url and digest for the matching extension | ||
|
|
||
| :param cur_version: threshold verssion to filter out extensions. | ||
| """ | ||
| candidates = get_index_extensions(index_url=index_url).get(extension_name, []) | ||
| candidates = get_index_extensions(index_url=index_url, cli_ctx=cli_ctx).get(extension_name, []) | ||
|
|
||
| if not candidates: | ||
| raise NoExtensionCandidatesError("No extension found with name '{}'".format(extension_name)) | ||
|
|
@@ -88,6 +88,13 @@ def resolve_from_index(extension_name, cur_version=None, index_url=None, target_ | |
| download_url, digest = chosen.get('downloadUrl'), chosen.get('sha256Digest') | ||
| if not download_url: | ||
| raise NoExtensionCandidatesError("No download url found.") | ||
| ext_endpoint = cli_ctx.cloud.endpoints.extension_storage_account_resource_id if cli_ctx and \ | ||
| cli_ctx.cloud.endpoints.has_endpoint_set('extension_storage_account_resource_id') else None | ||
| config_index_url = cli_ctx.config.get('extension', 'index_url', None) if cli_ctx else None | ||
|
Contributor
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. Maybe we can put these 2 URLs in one place?
Contributor
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. Also, isn't the
Member
Author
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. The index will be teleported into different storage accounts in air gapped clouds, we do not have permission to modify the whl
Contributor
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. Do we really need to put one URL in cloud config, one in
Member
Author
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. The one in cloud config is now a general support for downloading extensions and other tools/files needed in air gapped clouds. It's always a storage account endpoint and controlled by Microsoft. The one in |
||
| if ext_endpoint and not config_index_url: | ||
| import posixpath | ||
| whl_name = download_url.split('/')[-1] | ||
| download_url = posixpath.join(ext_endpoint, whl_name) | ||
| return download_url, digest | ||
|
|
||
|
|
||
|
|
||
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.
extension_pacakges_url?