From d5f1772442004e60eb244a2c91811604badca20f Mon Sep 17 00:00:00 2001 From: Adi Yadav Date: Wed, 31 Jan 2018 19:08:13 -0500 Subject: [PATCH 1/7] Added the extra-index-urls change to az extension add and update commands. --- .../cli/command_modules/extension/__init__.py | 10 ++++++++++ .../azure/cli/command_modules/extension/custom.py | 15 ++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py index eb27116c5f4..97190ce4228 100644 --- a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py +++ b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py @@ -60,6 +60,16 @@ def load_arguments(self, command): c.argument('extension_name', completer=extension_name_from_index_completion_list) c.argument('source', options_list=['--source', '-s'], help='Filepath or URL to an extension', completer=FilesCompleter()) c.argument('yes', options_list=['--yes', '-y'], action='store_true', help='Do not prompt for confirmation.') + c.argument('extra_index_urls', options_list=['--extra-index-url'], action='append', + help='Extra URLs of package indexes to use. This should point to a repository compliant ' + 'with PEP 503 (the simple repository API) or a local directory laid out in the same ' + 'format. Similar to the equivalent flag in pip install.') + + with self.argument_context('extension update') as c: + c.argument('extra_index_urls', options_list=['--extra-index-url'], action='append', + help='Extra URLs of package indexes to use. This should point to a repository compliant ' + 'with PEP 503 (the simple repository API) or a local directory laid out in the same ' + 'format. Similar to the equivalent flag in pip install.') COMMAND_LOADER_CLS = ExtensionCommandsLoader diff --git a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/custom.py b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/custom.py index 62c78b08f27..82933519862 100644 --- a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/custom.py +++ b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/custom.py @@ -86,7 +86,7 @@ def _validate_whl_extension(ext_file): _validate_whl_cli_compat(azext_metadata) -def _add_whl_ext(source, ext_sha256=None): # pylint: disable=too-many-statements +def _add_whl_ext(source, ext_sha256=None, extra_index_urls=None): # pylint: disable=too-many-statements if not source.endswith('.whl'): raise ValueError('Unknown extension type. Only Python wheels are supported.') url_parse_result = urlparse(source) @@ -138,6 +138,11 @@ def _add_whl_ext(source, ext_sha256=None): # pylint: disable=too-many-statement # Install with pip extension_path = get_extension_path(extension_name) pip_args = ['install', '--target', extension_path, ext_file] + + if extra_index_urls: + for extra_index_url in extra_index_urls: + pip_args = pip_args + ['--extra-index-url', extra_index_url] + logger.debug('Executing pip with args: %s', pip_args) with HomebrewPipPatch(): pip_status_code = _run_pip(pip_args) @@ -160,7 +165,7 @@ def is_valid_sha256sum(a_file, expected_sum): return expected_sum == computed_hash, computed_hash -def add_extension(source=None, extension_name=None, index_url=None, yes=None): # pylint: disable=unused-argument +def add_extension(source=None, extension_name=None, index_url=None, yes=None, extra_index_urls=None): # pylint: disable=unused-argument ext_sha256 = None if extension_name: if extension_exists(extension_name): @@ -170,7 +175,7 @@ def add_extension(source=None, extension_name=None, index_url=None, yes=None): except NoExtensionCandidatesError as err: logger.debug(err) raise CLIError("No matching extensions for '{}'. Use --debug for more information.".format(extension_name)) - _add_whl_ext(source, ext_sha256=ext_sha256) + _add_whl_ext(source, ext_sha256=ext_sha256, extra_index_urls=extra_index_urls) def remove_extension(extension_name): @@ -197,7 +202,7 @@ def show_extension(extension_name): raise CLIError(e) -def update_extension(extension_name, index_url=None): +def update_extension(extension_name, index_url=None, extra_index_urls=None): try: ext = get_extension(extension_name) cur_version = ext.get_version() @@ -215,7 +220,7 @@ def update_extension(extension_name, index_url=None): shutil.rmtree(extension_path) # Install newer version try: - _add_whl_ext(download_url, ext_sha256=ext_sha256) + _add_whl_ext(download_url, ext_sha256=ext_sha256, extra_index_urls=extra_index_urls) logger.debug('Deleting backup of old extension at %s', backup_dir) shutil.rmtree(backup_dir) except Exception as err: From 6fb336db01d6dca3c8acddc23ea0c29f99433267 Mon Sep 17 00:00:00 2001 From: Adi Yadav Date: Thu, 1 Feb 2018 00:06:27 -0500 Subject: [PATCH 2/7] Bumped the version. --- src/command_modules/azure-cli-extension/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command_modules/azure-cli-extension/setup.py b/src/command_modules/azure-cli-extension/setup.py index 5650c83d436..6d4812a7676 100644 --- a/src/command_modules/azure-cli-extension/setup.py +++ b/src/command_modules/azure-cli-extension/setup.py @@ -14,7 +14,7 @@ logger.warn("Wheel is not available, disabling bdist_wheel hook") cmdclass = {} -VERSION = "0.0.8" +VERSION = "0.0.9" CLASSIFIERS = [ 'Development Status :: 5 - Production/Stable', From 6785e8ce2fc7752e834babccf01e6521aa295e00 Mon Sep 17 00:00:00 2001 From: Adi Yadav <32306843+adyada@users.noreply.github.com> Date: Thu, 1 Feb 2018 17:25:11 -0500 Subject: [PATCH 3/7] Added --extra-index-url support. Added tests. (#1) * Update History.rst file. * Added first version of az extension add --extra-index-url test. * Added first version of az extension add --extra-index-url test. * Pep8 fixing * Pep8 fixing. * Pep 8 fix. * Modified the extra-index-url test. Modified the code to give preference to --extra-index-urls * Added some bebug statement. * Hopefully all build problems fixed. * Hopefully all build problems fixed. * Removed prints. --- .../azure-cli-extension/HISTORY.rst | 4 +++ .../cli/command_modules/extension/__init__.py | 18 +++++----- .../cli/command_modules/extension/custom.py | 11 ++++-- .../tests/latest/test_extension_commands.py | 35 +++++++++++++++++++ 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/src/command_modules/azure-cli-extension/HISTORY.rst b/src/command_modules/azure-cli-extension/HISTORY.rst index 5c0a9157c66..d91f7346fcb 100644 --- a/src/command_modules/azure-cli-extension/HISTORY.rst +++ b/src/command_modules/azure-cli-extension/HISTORY.rst @@ -2,6 +2,10 @@ Release History =============== +0.0.9 +++++++ +Added support for a hidden -extra-index-url to extension add and update commands. + 0.0.8 ++++++ Minor fixes diff --git a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py index 97190ce4228..d96a3044a3b 100644 --- a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py +++ b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py @@ -60,16 +60,18 @@ def load_arguments(self, command): c.argument('extension_name', completer=extension_name_from_index_completion_list) c.argument('source', options_list=['--source', '-s'], help='Filepath or URL to an extension', completer=FilesCompleter()) c.argument('yes', options_list=['--yes', '-y'], action='store_true', help='Do not prompt for confirmation.') - c.argument('extra_index_urls', options_list=['--extra-index-url'], action='append', - help='Extra URLs of package indexes to use. This should point to a repository compliant ' - 'with PEP 503 (the simple repository API) or a local directory laid out in the same ' - 'format. Similar to the equivalent flag in pip install.') + + # Help, because it is suppressed. + # Extra URLs of package indexes to use. This should point to a repository compliant + # with PEP 503 (the simple repository API) or a local directory laid out in the same format. + # Similar to the equivalent flag in pip install. But, the python indexes + # specified using --extra-index-url have higher precedence than https://pypi.python.org/simple + c.argument('extra_index_urls', options_list=['--extra-index-url'], nargs='+', + help=argparse.SUPPRESS) with self.argument_context('extension update') as c: - c.argument('extra_index_urls', options_list=['--extra-index-url'], action='append', - help='Extra URLs of package indexes to use. This should point to a repository compliant ' - 'with PEP 503 (the simple repository API) or a local directory laid out in the same ' - 'format. Similar to the equivalent flag in pip install.') + c.argument('extra_index_urls', options_list=['--extra-index-url'], nargs='+', + help=argparse.SUPPRESS) COMMAND_LOADER_CLS = ExtensionCommandsLoader diff --git a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/custom.py b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/custom.py index 82933519862..548abe79ef7 100644 --- a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/custom.py +++ b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/custom.py @@ -140,8 +140,15 @@ def _add_whl_ext(source, ext_sha256=None, extra_index_urls=None): # pylint: dis pip_args = ['install', '--target', extension_path, ext_file] if extra_index_urls: - for extra_index_url in extra_index_urls: - pip_args = pip_args + ['--extra-index-url', extra_index_url] + # We prefer the user given python index over PyPi, so that + # a user's packages are not mistaken for some other same name packages on PyPi + pip_args = pip_args + ['--index-url', extra_index_urls[0]] + pip_args = pip_args + ['--extra-index-url'] + for extra_index_url in extra_index_urls[1:]: + pip_args = pip_args + [extra_index_url] + + # Adding the PyPi in the end. + pip_args = pip_args + ["https://pypi.python.org/simple"] logger.debug('Executing pip with args: %s', pip_args) with HomebrewPipPatch(): diff --git a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/tests/latest/test_extension_commands.py b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/tests/latest/test_extension_commands.py index ddf77ed784c..860852ddcc8 100644 --- a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/tests/latest/test_extension_commands.py +++ b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/tests/latest/test_extension_commands.py @@ -185,6 +185,41 @@ def test_list_available_extensions_custom_index_url(self): list_available_extensions(index_url=index_url) c.assert_called_once_with(index_url) + def test_add_list_show_remove_extension_extra_index_url(self): + """ + Tests extension addition while specifying --extra-index-url parameter. + :return: + """ + test_index = 'https://testpypi.python.org/simple' + + add_extension(source=MY_EXT_SOURCE, extra_index_urls=[test_index]) + actual = list_extensions() + self.assertEqual(len(actual), 1) + ext = show_extension(MY_EXT_NAME) + self.assertEqual(ext[OUT_KEY_NAME], MY_EXT_NAME) + remove_extension(MY_EXT_NAME) + num_exts = len(list_extensions()) + self.assertEqual(num_exts, 0) + + def test_update_extension_extra_index_url(self): + """ + Tests extension update while specifying --extra-index-url parameter. + :return: + """ + test_index = 'https://testpypi.python.org/simple' + add_extension(source=MY_EXT_SOURCE, extra_index_urls=[test_index]) + ext = show_extension(MY_EXT_NAME) + self.assertEqual(ext[OUT_KEY_VERSION], '0.0.3+dev') + newer_extension = _get_test_data_file('myfirstcliextension-0.0.4+dev-py2.py3-none-any.whl') + computed_extension_sha256 = _compute_file_hash(newer_extension) + with mock.patch('azure.cli.command_modules.extension.custom.resolve_from_index', return_value=(newer_extension, computed_extension_sha256)): + update_extension(MY_EXT_NAME, extra_index_urls=[test_index]) + ext = show_extension(MY_EXT_NAME) + self.assertEqual(ext[OUT_KEY_VERSION], '0.0.4+dev') + # Removing extension for cleanup of this test. + remove_extension(MY_EXT_NAME) + pass + if __name__ == '__main__': unittest.main() From de0a10707c7bc4e25c7d7431f37d9db312aed418 Mon Sep 17 00:00:00 2001 From: Adi Yadav <32306843+adyada@users.noreply.github.com> Date: Fri, 2 Feb 2018 11:25:31 -0500 Subject: [PATCH 4/7] Resolved PR comments. (#2) --- src/command_modules/azure-cli-extension/HISTORY.rst | 2 +- .../azure/cli/command_modules/extension/__init__.py | 12 ++++-------- .../tests/latest/test_extension_commands.py | 3 --- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/command_modules/azure-cli-extension/HISTORY.rst b/src/command_modules/azure-cli-extension/HISTORY.rst index d91f7346fcb..8d0e38befa2 100644 --- a/src/command_modules/azure-cli-extension/HISTORY.rst +++ b/src/command_modules/azure-cli-extension/HISTORY.rst @@ -4,7 +4,7 @@ Release History =============== 0.0.9 ++++++ -Added support for a hidden -extra-index-url to extension add and update commands. +Added support for --extra-index-url argument to az extension add and update commands. 0.0.8 ++++++ diff --git a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py index d96a3044a3b..481ffacfde7 100644 --- a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py +++ b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py @@ -56,11 +56,6 @@ def load_arguments(self, command): # This is a hidden parameter for now c.argument('index_url', options_list=['--index'], help=argparse.SUPPRESS) - with self.argument_context('extension add') as c: - c.argument('extension_name', completer=extension_name_from_index_completion_list) - c.argument('source', options_list=['--source', '-s'], help='Filepath or URL to an extension', completer=FilesCompleter()) - c.argument('yes', options_list=['--yes', '-y'], action='store_true', help='Do not prompt for confirmation.') - # Help, because it is suppressed. # Extra URLs of package indexes to use. This should point to a repository compliant # with PEP 503 (the simple repository API) or a local directory laid out in the same format. @@ -69,9 +64,10 @@ def load_arguments(self, command): c.argument('extra_index_urls', options_list=['--extra-index-url'], nargs='+', help=argparse.SUPPRESS) - with self.argument_context('extension update') as c: - c.argument('extra_index_urls', options_list=['--extra-index-url'], nargs='+', - help=argparse.SUPPRESS) + with self.argument_context('extension add') as c: + c.argument('extension_name', completer=extension_name_from_index_completion_list) + c.argument('source', options_list=['--source', '-s'], help='Filepath or URL to an extension', completer=FilesCompleter()) + c.argument('yes', options_list=['--yes', '-y'], action='store_true', help='Do not prompt for confirmation.') COMMAND_LOADER_CLS = ExtensionCommandsLoader diff --git a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/tests/latest/test_extension_commands.py b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/tests/latest/test_extension_commands.py index 860852ddcc8..b62845c73e6 100644 --- a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/tests/latest/test_extension_commands.py +++ b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/tests/latest/test_extension_commands.py @@ -216,9 +216,6 @@ def test_update_extension_extra_index_url(self): update_extension(MY_EXT_NAME, extra_index_urls=[test_index]) ext = show_extension(MY_EXT_NAME) self.assertEqual(ext[OUT_KEY_VERSION], '0.0.4+dev') - # Removing extension for cleanup of this test. - remove_extension(MY_EXT_NAME) - pass if __name__ == '__main__': From 6002b33744530fac5089ee033cfd6c580ad98975 Mon Sep 17 00:00:00 2001 From: Adi Yadav <32306843+adyada@users.noreply.github.com> Date: Mon, 5 Feb 2018 18:03:24 -0500 Subject: [PATCH 5/7] Removed precedence for extra index urls * Resolved PR comments. * Removed unnecessary extra index url precedence logic. --- .../azure/cli/command_modules/extension/__init__.py | 3 +-- .../azure/cli/command_modules/extension/custom.py | 10 +--------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py index 481ffacfde7..361efff40ed 100644 --- a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py +++ b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py @@ -59,8 +59,7 @@ def load_arguments(self, command): # Help, because it is suppressed. # Extra URLs of package indexes to use. This should point to a repository compliant # with PEP 503 (the simple repository API) or a local directory laid out in the same format. - # Similar to the equivalent flag in pip install. But, the python indexes - # specified using --extra-index-url have higher precedence than https://pypi.python.org/simple + # Similar to the equivalent flag in pip install. c.argument('extra_index_urls', options_list=['--extra-index-url'], nargs='+', help=argparse.SUPPRESS) diff --git a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/custom.py b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/custom.py index 548abe79ef7..cd5fe910e30 100644 --- a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/custom.py +++ b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/custom.py @@ -140,15 +140,7 @@ def _add_whl_ext(source, ext_sha256=None, extra_index_urls=None): # pylint: dis pip_args = ['install', '--target', extension_path, ext_file] if extra_index_urls: - # We prefer the user given python index over PyPi, so that - # a user's packages are not mistaken for some other same name packages on PyPi - pip_args = pip_args + ['--index-url', extra_index_urls[0]] - pip_args = pip_args + ['--extra-index-url'] - for extra_index_url in extra_index_urls[1:]: - pip_args = pip_args + [extra_index_url] - - # Adding the PyPi in the end. - pip_args = pip_args + ["https://pypi.python.org/simple"] + pip_args = pip_args + ['--extra-index-url'] + extra_index_urls logger.debug('Executing pip with args: %s', pip_args) with HomebrewPipPatch(): From 023c7b973e56c1f26ca23aec5114ef5fdb45f497 Mon Sep 17 00:00:00 2001 From: Adi Yadav Date: Tue, 6 Feb 2018 13:29:35 -0500 Subject: [PATCH 6/7] Updated the version number. --- src/command_modules/azure-cli-extension/HISTORY.rst | 3 --- src/command_modules/azure-cli-extension/setup.py | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/command_modules/azure-cli-extension/HISTORY.rst b/src/command_modules/azure-cli-extension/HISTORY.rst index 2c15308e79e..a8369b2800d 100644 --- a/src/command_modules/azure-cli-extension/HISTORY.rst +++ b/src/command_modules/azure-cli-extension/HISTORY.rst @@ -2,9 +2,6 @@ Release History =============== -0.0.10 -++++++ -A bug fix in the --extra-index-url argument in az extension add and update commands. 0.0.9 ++++++ diff --git a/src/command_modules/azure-cli-extension/setup.py b/src/command_modules/azure-cli-extension/setup.py index 584b5d16b93..6d4812a7676 100644 --- a/src/command_modules/azure-cli-extension/setup.py +++ b/src/command_modules/azure-cli-extension/setup.py @@ -14,7 +14,7 @@ logger.warn("Wheel is not available, disabling bdist_wheel hook") cmdclass = {} -VERSION = "0.0.10" +VERSION = "0.0.9" CLASSIFIERS = [ 'Development Status :: 5 - Production/Stable', From ae01382d5d5f7d96f6a85bbc3dbf22d81311ef4c Mon Sep 17 00:00:00 2001 From: Adi Yadav Date: Tue, 6 Feb 2018 15:33:36 -0500 Subject: [PATCH 7/7] Changed the argument name. --- .../azure-cli-extension/HISTORY.rst | 2 +- .../cli/command_modules/extension/__init__.py | 2 +- .../azure/cli/command_modules/extension/custom.py | 14 +++++++------- .../tests/latest/test_extension_commands.py | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/command_modules/azure-cli-extension/HISTORY.rst b/src/command_modules/azure-cli-extension/HISTORY.rst index a8369b2800d..2e18b60ef73 100644 --- a/src/command_modules/azure-cli-extension/HISTORY.rst +++ b/src/command_modules/azure-cli-extension/HISTORY.rst @@ -5,7 +5,7 @@ Release History 0.0.9 ++++++ -Added support for --extra-index-url argument to az extension add and update commands. +Added support for --pip-extra-index-urls argument to az extension add and update commands. 0.0.8 ++++++ diff --git a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py index 361efff40ed..fc4aae8f0e7 100644 --- a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py +++ b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/__init__.py @@ -60,7 +60,7 @@ def load_arguments(self, command): # Extra URLs of package indexes to use. This should point to a repository compliant # with PEP 503 (the simple repository API) or a local directory laid out in the same format. # Similar to the equivalent flag in pip install. - c.argument('extra_index_urls', options_list=['--extra-index-url'], nargs='+', + c.argument('pip_extra_index_urls', options_list=['--pip-extra-index-urls'], nargs='+', help=argparse.SUPPRESS) with self.argument_context('extension add') as c: diff --git a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/custom.py b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/custom.py index 82933519862..21e3b6d340b 100644 --- a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/custom.py +++ b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/custom.py @@ -86,7 +86,7 @@ def _validate_whl_extension(ext_file): _validate_whl_cli_compat(azext_metadata) -def _add_whl_ext(source, ext_sha256=None, extra_index_urls=None): # pylint: disable=too-many-statements +def _add_whl_ext(source, ext_sha256=None, pip_extra_index_urls=None): # pylint: disable=too-many-statements if not source.endswith('.whl'): raise ValueError('Unknown extension type. Only Python wheels are supported.') url_parse_result = urlparse(source) @@ -139,8 +139,8 @@ def _add_whl_ext(source, ext_sha256=None, extra_index_urls=None): # pylint: dis extension_path = get_extension_path(extension_name) pip_args = ['install', '--target', extension_path, ext_file] - if extra_index_urls: - for extra_index_url in extra_index_urls: + if pip_extra_index_urls: + for extra_index_url in pip_extra_index_urls: pip_args = pip_args + ['--extra-index-url', extra_index_url] logger.debug('Executing pip with args: %s', pip_args) @@ -165,7 +165,7 @@ def is_valid_sha256sum(a_file, expected_sum): return expected_sum == computed_hash, computed_hash -def add_extension(source=None, extension_name=None, index_url=None, yes=None, extra_index_urls=None): # pylint: disable=unused-argument +def add_extension(source=None, extension_name=None, index_url=None, yes=None, pip_extra_index_urls=None): # pylint: disable=unused-argument ext_sha256 = None if extension_name: if extension_exists(extension_name): @@ -175,7 +175,7 @@ def add_extension(source=None, extension_name=None, index_url=None, yes=None, ex except NoExtensionCandidatesError as err: logger.debug(err) raise CLIError("No matching extensions for '{}'. Use --debug for more information.".format(extension_name)) - _add_whl_ext(source, ext_sha256=ext_sha256, extra_index_urls=extra_index_urls) + _add_whl_ext(source, ext_sha256=ext_sha256, pip_extra_index_urls=pip_extra_index_urls) def remove_extension(extension_name): @@ -202,7 +202,7 @@ def show_extension(extension_name): raise CLIError(e) -def update_extension(extension_name, index_url=None, extra_index_urls=None): +def update_extension(extension_name, index_url=None, pip_extra_index_urls=None): try: ext = get_extension(extension_name) cur_version = ext.get_version() @@ -220,7 +220,7 @@ def update_extension(extension_name, index_url=None, extra_index_urls=None): shutil.rmtree(extension_path) # Install newer version try: - _add_whl_ext(download_url, ext_sha256=ext_sha256, extra_index_urls=extra_index_urls) + _add_whl_ext(download_url, ext_sha256=ext_sha256, pip_extra_index_urls=pip_extra_index_urls) logger.debug('Deleting backup of old extension at %s', backup_dir) shutil.rmtree(backup_dir) except Exception as err: diff --git a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/tests/latest/test_extension_commands.py b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/tests/latest/test_extension_commands.py index 1ec057a41ce..9ee0a234690 100644 --- a/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/tests/latest/test_extension_commands.py +++ b/src/command_modules/azure-cli-extension/azure/cli/command_modules/extension/tests/latest/test_extension_commands.py @@ -192,7 +192,7 @@ def test_add_list_show_remove_extension_extra_index_url(self): """ extra_index_urls = ['https://testpypi.python.org/simple', 'https://pypi.python.org/simple'] - add_extension(source=MY_EXT_SOURCE, extra_index_urls=extra_index_urls) + add_extension(source=MY_EXT_SOURCE, pip_extra_index_urls=extra_index_urls) actual = list_extensions() self.assertEqual(len(actual), 1) ext = show_extension(MY_EXT_NAME) @@ -208,13 +208,13 @@ def test_update_extension_extra_index_url(self): """ extra_index_urls = ['https://testpypi.python.org/simple', 'https://pypi.python.org/simple'] - add_extension(source=MY_EXT_SOURCE, extra_index_urls=extra_index_urls) + add_extension(source=MY_EXT_SOURCE, pip_extra_index_urls=extra_index_urls) ext = show_extension(MY_EXT_NAME) self.assertEqual(ext[OUT_KEY_VERSION], '0.0.3+dev') newer_extension = _get_test_data_file('myfirstcliextension-0.0.4+dev-py2.py3-none-any.whl') computed_extension_sha256 = _compute_file_hash(newer_extension) with mock.patch('azure.cli.command_modules.extension.custom.resolve_from_index', return_value=(newer_extension, computed_extension_sha256)): - update_extension(MY_EXT_NAME, extra_index_urls=extra_index_urls) + update_extension(MY_EXT_NAME, pip_extra_index_urls=extra_index_urls) ext = show_extension(MY_EXT_NAME) self.assertEqual(ext[OUT_KEY_VERSION], '0.0.4+dev')