From 44414d1cadf2ef42e207694e4fce7bf6139ee34e Mon Sep 17 00:00:00 2001 From: Saurabh Sarkar Date: Thu, 24 May 2018 16:55:03 -0700 Subject: [PATCH 1/5] Updating space select - selecting space on resource create/select both - updating azds osx url --- .../azext_dev_spaces_preview/custom.py | 34 ++++++++++--------- src/dev-spaces-preview/setup.py | 2 +- src/index.json | 8 ++--- 3 files changed, 23 insertions(+), 21 deletions(-) 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 606739008fe..94975967658 100644 --- a/src/dev-spaces-preview/azext_dev_spaces_preview/custom.py +++ b/src/dev-spaces-preview/azext_dev_spaces_preview/custom.py @@ -38,33 +38,35 @@ def ads_use_dev_spaces(cluster_name, resource_group_name, space_name='default', from subprocess import PIPE should_create_resource = False + create_resource_ret_code = 0 retCode = subprocess.call( [azds_cli, 'resource', 'select', '-n', cluster_name, '-g', resource_group_name], stderr=PIPE) if retCode == 1: should_create_resource = True + create_resource_ret_code = 1 if should_create_resource: - retCode = subprocess.call( + create_resource_ret_code = subprocess.call( [azds_cli, 'resource', 'create', '--aks-name', cluster_name, '--aks-resource-group', resource_group_name, '--name', cluster_name, '--resource-group', resource_group_name], universal_newlines=True) - if retCode == 0: - should_create_spaces = False - create_space_arguments = [azds_cli, 'space', 'select', '--name', space_name] - if parent_space_name is not None: - create_space_arguments.append('--parent') - create_space_arguments.append(parent_space_name) - retCode = subprocess.call( - create_space_arguments, stderr=PIPE) - if retCode == 1: - should_create_spaces = True + if create_resource_ret_code == 0: + should_create_spaces = False + create_space_arguments = [azds_cli, 'space', 'select', '--name', space_name] + if parent_space_name is not None: + create_space_arguments.append('--parent') + create_space_arguments.append(parent_space_name) + retCode = subprocess.call( + create_space_arguments, stderr=PIPE) + if retCode == 1: + should_create_spaces = True - if should_create_spaces: - subprocess.call( - [azds_cli, 'space', 'create', '--name', space_name], - universal_newlines=True) + if should_create_spaces: + subprocess.call( + [azds_cli, 'space', 'create', '--name', space_name], + universal_newlines=True) def ads_remove_dev_spaces(cluster_name, resource_group_name, prompt=False): # pylint: disable=line-too-long @@ -121,7 +123,7 @@ def _install_dev_spaces_cli(): # OSX azds_cli = 'azds' setup_file = os.path.join(_create_tmp_dir(), 'azds-osx-setup.sh') - setup_url = "https://aka.ms/get-azds-osx-az" + setup_url = "https://aka.ms/get-azds-mac-az" setup_args = ['bash', setup_file] elif system == 'Linux': # Linux diff --git a/src/dev-spaces-preview/setup.py b/src/dev-spaces-preview/setup.py index 4b492c16c52..ae3fc2187ab 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.1" +VERSION = "0.1.2" CLASSIFIERS = [ 'Development Status :: 4 - Beta', diff --git a/src/index.json b/src/index.json index ae3f558c5d0..11429662f67 100644 --- a/src/index.json +++ b/src/index.json @@ -326,9 +326,9 @@ ], "dev-spaces-preview": [ { - "filename": "dev_spaces_preview-0.1.1-py2.py3-none-any.whl", - "sha256Digest": "59557d90999178dddbdcb14590202efe3d4d016186484ce33cfe0984a312c73b", - "downloadUrl": "https://azuredevspacestools.blob.core.windows.net/azdssetup/LKS/dev_spaces_preview-0.1.1-py2.py3-none-any.whl", + "filename": "dev_spaces_preview-0.1.2-py2.py3-none-any.whl", + "sha256Digest": "f508828a91a9a1589c58250e29d7271dcc81e9f050aeab5335e91dc825a69ca0", + "downloadUrl": "https://azuredevspacestools.blob.core.windows.net/azdssetup/LKS/dev_spaces_preview-0.1.2-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.1" + "version": "0.1.2" } } ], From 641ee2690c357e70b45cef363fbed42a71a267c6 Mon Sep 17 00:00:00 2001 From: Saurabh Sarkar Date: Thu, 24 May 2018 16:57:15 -0700 Subject: [PATCH 2/5] Update --- src/dev-spaces-preview/azext_dev_spaces_preview/custom.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 94975967658..134aae2cb55 100644 --- a/src/dev-spaces-preview/azext_dev_spaces_preview/custom.py +++ b/src/dev-spaces-preview/azext_dev_spaces_preview/custom.py @@ -15,10 +15,10 @@ logger = get_logger(__name__) -# pylint:disable=no-member,too-many-lines,too-many-locals,too-many-statements +# 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): # pylint: disable=line-too-long +def ads_use_dev_spaces(cluster_name, resource_group_name, space_name='default', parent_space_name=None): """ Use Azure Dev Spaces with a managed Kubernetes cluster. @@ -69,7 +69,7 @@ def ads_use_dev_spaces(cluster_name, resource_group_name, space_name='default', universal_newlines=True) -def ads_remove_dev_spaces(cluster_name, resource_group_name, prompt=False): # pylint: disable=line-too-long +def ads_remove_dev_spaces(cluster_name, resource_group_name, prompt=False): """ Remove Azure Dev Spaces from a managed Kubernetes cluster. From c073087e8af92430d3e49118db208b606328e7f0 Mon Sep 17 00:00:00 2001 From: Saurabh Sarkar Date: Thu, 24 May 2018 20:49:29 -0700 Subject: [PATCH 3/5] CR --- .../azext_dev_spaces_preview/custom.py | 23 +++++-------------- src/index.json | 2 +- 2 files changed, 7 insertions(+), 18 deletions(-) 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 134aae2cb55..76fbe2a8c5f 100644 --- a/src/dev-spaces-preview/azext_dev_spaces_preview/custom.py +++ b/src/dev-spaces-preview/azext_dev_spaces_preview/custom.py @@ -37,36 +37,25 @@ def ads_use_dev_spaces(cluster_name, resource_group_name, space_name='default', azds_cli = _install_dev_spaces_cli() from subprocess import PIPE - should_create_resource = False create_resource_ret_code = 0 retCode = subprocess.call( [azds_cli, 'resource', 'select', '-n', cluster_name, '-g', resource_group_name], stderr=PIPE) if retCode == 1: - should_create_resource = True - create_resource_ret_code = 1 - - if should_create_resource: create_resource_ret_code = subprocess.call( [azds_cli, 'resource', 'create', '--aks-name', cluster_name, '--aks-resource-group', resource_group_name, '--name', cluster_name, '--resource-group', resource_group_name], universal_newlines=True) if create_resource_ret_code == 0: - should_create_spaces = False - create_space_arguments = [azds_cli, 'space', 'select', '--name', space_name] - if parent_space_name is not None: - create_space_arguments.append('--parent') - create_space_arguments.append(parent_space_name) retCode = subprocess.call( - create_space_arguments, stderr=PIPE) + [azds_cli, 'space', 'select', '--name', space_name], stderr=PIPE) if retCode == 1: - should_create_spaces = True - - if should_create_spaces: - subprocess.call( - [azds_cli, 'space', 'create', '--name', space_name], - universal_newlines=True) + create_space_arguments = [azds_cli, 'space', 'create', '--name', space_name] + if parent_space_name is not None: + create_space_arguments.append('--parent') + create_space_arguments.append(parent_space_name) + subprocess.call(create_space_arguments, universal_newlines=True) def ads_remove_dev_spaces(cluster_name, resource_group_name, prompt=False): diff --git a/src/index.json b/src/index.json index 11429662f67..76db9c380bf 100644 --- a/src/index.json +++ b/src/index.json @@ -327,7 +327,7 @@ "dev-spaces-preview": [ { "filename": "dev_spaces_preview-0.1.2-py2.py3-none-any.whl", - "sha256Digest": "f508828a91a9a1589c58250e29d7271dcc81e9f050aeab5335e91dc825a69ca0", + "sha256Digest": "7fada4c466fa0367e02d622e9d78c5f39393171ff81b379337e93e4809027ecc", "downloadUrl": "https://azuredevspacestools.blob.core.windows.net/azdssetup/LKS/dev_spaces_preview-0.1.2-py2.py3-none-any.whl", "metadata": { "azext.isPreview": true, From e569117a12cbd3348b09b6ab6d555fc14752bb2a Mon Sep 17 00:00:00 2001 From: Saurabh Sarkar Date: Fri, 25 May 2018 11:37:51 -0700 Subject: [PATCH 4/5] Adding comments --- src/dev-spaces-preview/azext_dev_spaces_preview/custom.py | 6 +++--- src/index.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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 76fbe2a8c5f..c0fbe660055 100644 --- a/src/dev-spaces-preview/azext_dev_spaces_preview/custom.py +++ b/src/dev-spaces-preview/azext_dev_spaces_preview/custom.py @@ -37,17 +37,17 @@ def ads_use_dev_spaces(cluster_name, resource_group_name, space_name='default', azds_cli = _install_dev_spaces_cli() from subprocess import PIPE - create_resource_ret_code = 0 + resource_ready_code = 0 # Flag if the resource is ready, after create or select retCode = subprocess.call( [azds_cli, 'resource', 'select', '-n', cluster_name, '-g', resource_group_name], stderr=PIPE) if retCode == 1: - create_resource_ret_code = subprocess.call( + resource_ready_code = subprocess.call( [azds_cli, 'resource', 'create', '--aks-name', cluster_name, '--aks-resource-group', resource_group_name, '--name', cluster_name, '--resource-group', resource_group_name], universal_newlines=True) - if create_resource_ret_code == 0: + if resource_ready_code == 0: retCode = subprocess.call( [azds_cli, 'space', 'select', '--name', space_name], stderr=PIPE) if retCode == 1: diff --git a/src/index.json b/src/index.json index 647af33c29c..249170a9524 100644 --- a/src/index.json +++ b/src/index.json @@ -327,7 +327,7 @@ "dev-spaces-preview": [ { "filename": "dev_spaces_preview-0.1.2-py2.py3-none-any.whl", - "sha256Digest": "7fada4c466fa0367e02d622e9d78c5f39393171ff81b379337e93e4809027ecc", + "sha256Digest": "8340177da62d95e68cabe9958509a8272052cb2b889fd8c150c6ec1a1f66a4e6", "downloadUrl": "https://azuredevspacestools.blob.core.windows.net/azdssetup/LKS/dev_spaces_preview-0.1.2-py2.py3-none-any.whl", "metadata": { "azext.isPreview": true, From 413fdcc71f83d08e2230696a9145c30ea6e4f218 Mon Sep 17 00:00:00 2001 From: Saurabh Sarkar Date: Fri, 25 May 2018 13:13:31 -0700 Subject: [PATCH 5/5] CR --- .../azext_dev_spaces_preview/custom.py | 26 ++++++++++--------- src/index.json | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) 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 c0fbe660055..c41a62e4cf7 100644 --- a/src/dev-spaces-preview/azext_dev_spaces_preview/custom.py +++ b/src/dev-spaces-preview/azext_dev_spaces_preview/custom.py @@ -37,25 +37,27 @@ def ads_use_dev_spaces(cluster_name, resource_group_name, space_name='default', azds_cli = _install_dev_spaces_cli() from subprocess import PIPE - resource_ready_code = 0 # Flag if the resource is ready, after create or select retCode = subprocess.call( [azds_cli, 'resource', 'select', '-n', cluster_name, '-g', resource_group_name], stderr=PIPE) - if retCode == 1: - resource_ready_code = subprocess.call( + if retCode != 0: + retCode = subprocess.call( [azds_cli, 'resource', 'create', '--aks-name', cluster_name, '--aks-resource-group', resource_group_name, '--name', cluster_name, '--resource-group', resource_group_name], universal_newlines=True) + if retCode != 0: + return - if resource_ready_code == 0: - retCode = subprocess.call( - [azds_cli, 'space', 'select', '--name', space_name], stderr=PIPE) - if retCode == 1: - create_space_arguments = [azds_cli, 'space', 'create', '--name', space_name] - if parent_space_name is not None: - create_space_arguments.append('--parent') - create_space_arguments.append(parent_space_name) - subprocess.call(create_space_arguments, universal_newlines=True) + retCode = subprocess.call( + [azds_cli, 'space', 'select', '--name', space_name], stderr=PIPE) + if retCode == 0: + return + + create_space_arguments = [azds_cli, 'space', 'create', '--name', space_name] + if parent_space_name is not None: + create_space_arguments.append('--parent') + create_space_arguments.append(parent_space_name) + subprocess.call(create_space_arguments, universal_newlines=True) def ads_remove_dev_spaces(cluster_name, resource_group_name, prompt=False): diff --git a/src/index.json b/src/index.json index 249170a9524..a7a8d32c29a 100644 --- a/src/index.json +++ b/src/index.json @@ -327,7 +327,7 @@ "dev-spaces-preview": [ { "filename": "dev_spaces_preview-0.1.2-py2.py3-none-any.whl", - "sha256Digest": "8340177da62d95e68cabe9958509a8272052cb2b889fd8c150c6ec1a1f66a4e6", + "sha256Digest": "84d0470bb45cee94f62580927dc5ed2ab5be9e110ce8f836153e277f7547e012", "downloadUrl": "https://azuredevspacestools.blob.core.windows.net/azdssetup/LKS/dev_spaces_preview-0.1.2-py2.py3-none-any.whl", "metadata": { "azext.isPreview": true,