From f071c65d6fe806f7ddfb29a155761d8e9ff74aac Mon Sep 17 00:00:00 2001 From: Saurabh Sarkar Date: Fri, 1 Jun 2018 16:52:37 -0700 Subject: [PATCH] Updating dev-spaces-preview extension to honor azds commands update (#196) * Updating dev-spaces-preview extension to honor azds commands update * Adding update option to force install the newer version of azds tool * Update remove command * Index Update --- .../azext_dev_spaces_preview/__init__.py | 1 + .../azext_dev_spaces_preview/_help.py | 3 +++ .../azext_dev_spaces_preview/custom.py | 18 ++++++++++-------- src/dev-spaces-preview/setup.py | 2 +- src/index.json | 8 ++++---- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/dev-spaces-preview/azext_dev_spaces_preview/__init__.py b/src/dev-spaces-preview/azext_dev_spaces_preview/__init__.py index 8158947a5f6..dcc54359b78 100644 --- a/src/dev-spaces-preview/azext_dev_spaces_preview/__init__.py +++ b/src/dev-spaces-preview/azext_dev_spaces_preview/__init__.py @@ -31,6 +31,7 @@ def load_arguments(self, _): c.argument('resource_group_name', options_list=['--resource-group', '-g']) c.argument('space_name', options_list=['--space', '-s']) c.argument('parent_space_name', options_list=['--parent-space', '-p']) + c.argument('update', options_list=['--update'], action='store_true') with self.argument_context('ads remove') as c: c.argument('cluster_name', options_list=['--name', '-n']) diff --git a/src/dev-spaces-preview/azext_dev_spaces_preview/_help.py b/src/dev-spaces-preview/azext_dev_spaces_preview/_help.py index 74b506a7684..4cb32dde30e 100644 --- a/src/dev-spaces-preview/azext_dev_spaces_preview/_help.py +++ b/src/dev-spaces-preview/azext_dev_spaces_preview/_help.py @@ -29,6 +29,9 @@ - name: --parent-space -p type: string short-summary: Name of a parent dev space to inherit from when creating a new dev space. By default, if there is already a single dev space with no parent, the new space inherits from this one. + - name: --update + type: bool + short-summary: Update Azure Dev Spaces tools. """ helps['ads remove'] = """ diff --git a/src/dev-spaces-preview/azext_dev_spaces_preview/custom.py b/src/dev-spaces-preview/azext_dev_spaces_preview/custom.py index c41a62e4cf7..cb48818b045 100644 --- a/src/dev-spaces-preview/azext_dev_spaces_preview/custom.py +++ b/src/dev-spaces-preview/azext_dev_spaces_preview/custom.py @@ -18,7 +18,7 @@ # pylint:disable=no-member,too-many-lines,too-many-locals,too-many-statements,too-few-public-methods -def ads_use_dev_spaces(cluster_name, resource_group_name, space_name='default', parent_space_name=None): +def ads_use_dev_spaces(cluster_name, resource_group_name, space_name='default', parent_space_name=None, update=False): """ Use Azure Dev Spaces with a managed Kubernetes cluster. @@ -32,17 +32,19 @@ def ads_use_dev_spaces(cluster_name, resource_group_name, space_name='default', :param parent_space_name: Name of a parent dev space to inherit from when creating a new dev space. \ By default, if there is already a single dev space with no parent, the new space inherits from this one. :type parent_space_name: String + :param update: Update Azure Dev Spaces tools. + :type update: bool """ - azds_cli = _install_dev_spaces_cli() + azds_cli = _install_dev_spaces_cli(update) from subprocess import PIPE retCode = subprocess.call( - [azds_cli, 'resource', 'select', '-n', cluster_name, '-g', resource_group_name], + [azds_cli, 'controller', 'select', '--name', cluster_name, '--resource-group', resource_group_name], stderr=PIPE) if retCode != 0: retCode = subprocess.call( - [azds_cli, 'resource', 'create', '--aks-name', cluster_name, '--aks-resource-group', + [azds_cli, 'controller', 'create', '--target-name', cluster_name, '--target-resource-group', resource_group_name, '--name', cluster_name, '--resource-group', resource_group_name], universal_newlines=True) if retCode != 0: @@ -73,9 +75,9 @@ def ads_remove_dev_spaces(cluster_name, resource_group_name, prompt=False): :type prompt: bool """ - azds_cli = _install_dev_spaces_cli() + azds_cli = _install_dev_spaces_cli(False) - remove_command_arguments = [azds_cli, 'resource', 'rm', '--name', + remove_command_arguments = [azds_cli, 'controller', 'delete', '--name', cluster_name, '--resource-group', resource_group_name] if prompt: remove_command_arguments.append('-y') @@ -97,7 +99,7 @@ def _is_dev_spaces_installed(vsce_cli): return True -def _install_dev_spaces_cli(): +def _install_dev_spaces_cli(force_install): azds_tool = 'Azure Dev Spaces CLI' should_install_azds = False system = platform.system() @@ -125,7 +127,7 @@ def _install_dev_spaces_cli(): else: raise CLIError('Platform not supported: {}.'.format(system)) - should_install_azds = not _is_dev_spaces_installed(azds_cli) + should_install_azds = force_install | (not _is_dev_spaces_installed(azds_cli)) if should_install_azds: # Install AZDS diff --git a/src/dev-spaces-preview/setup.py b/src/dev-spaces-preview/setup.py index ae3fc2187ab..a08d80e1644 100644 --- a/src/dev-spaces-preview/setup.py +++ b/src/dev-spaces-preview/setup.py @@ -7,7 +7,7 @@ from setuptools import setup, find_packages -VERSION = "0.1.2" +VERSION = "0.1.3" CLASSIFIERS = [ 'Development Status :: 4 - Beta', diff --git a/src/index.json b/src/index.json index 1baee34edbf..5ce74717661 100644 --- a/src/index.json +++ b/src/index.json @@ -326,9 +326,9 @@ ], "dev-spaces-preview": [ { - "filename": "dev_spaces_preview-0.1.2-py2.py3-none-any.whl", - "sha256Digest": "84d0470bb45cee94f62580927dc5ed2ab5be9e110ce8f836153e277f7547e012", - "downloadUrl": "https://azuredevspacestools.blob.core.windows.net/azdssetup/LKS/dev_spaces_preview-0.1.2-py2.py3-none-any.whl", + "filename": "dev_spaces_preview-0.1.3-py2.py3-none-any.whl", + "sha256Digest": "3d431ce5a0f873b41c87dda411bec3a1851c9ac2cb86b566b5317980f3eb116b", + "downloadUrl": "https://azuredevspacestools.blob.core.windows.net/azdssetup/LKS/dev_spaces_preview-0.1.3-py2.py3-none-any.whl", "metadata": { "azext.isPreview": true, "azext.minCliCoreVersion": "2.0.32", @@ -367,7 +367,7 @@ "metadata_version": "2.0", "name": "dev-spaces-preview", "summary": "Dev Spaces provides a rapid, iterative Kubernetes development experience for teams.", - "version": "0.1.2" + "version": "0.1.3" } } ],