Skip to content
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

Updating space select functionality #191

Merged
merged 7 commits into from
May 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 16 additions & 23 deletions src/dev-spaces-preview/azext_dev_spaces_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -37,37 +37,30 @@ 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
retCode = subprocess.call(
[azds_cli, 'resource', 'select', '-n', cluster_name, '-g', resource_group_name],
stderr=PIPE)
if retCode == 1:
should_create_resource = True

if should_create_resource:
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 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
retCode = subprocess.call(
[azds_cli, 'space', 'select', '--name', space_name], stderr=PIPE)
if retCode == 0:
return

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): # 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.

Expand Down Expand Up @@ -121,7 +114,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
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.1"
VERSION = "0.1.2"

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.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": "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,
"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.1"
"version": "0.1.2"
}
}
],
Expand Down