Skip to content

Commit

Permalink
Updating dev-spaces-preview extension to honor azds commands update (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
saurabsa authored Jun 1, 2018
1 parent 2163288 commit f071c65
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
3 changes: 3 additions & 0 deletions src/dev-spaces-preview/azext_dev_spaces_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'] = """
Expand Down
18 changes: 10 additions & 8 deletions src/dev-spaces-preview/azext_dev_spaces_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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')
Expand All @@ -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()
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/dev-spaces-preview/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from setuptools import setup, find_packages

VERSION = "0.1.2"
VERSION = "0.1.3"

CLASSIFIERS = [
'Development Status :: 4 - Beta',
Expand Down
8 changes: 4 additions & 4 deletions src/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
],
Expand Down

0 comments on commit f071c65

Please sign in to comment.