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 az use call to azds cli #211

Merged
merged 14 commits into from
Jun 20, 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
57 changes: 22 additions & 35 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


def ads_use_dev_spaces(cluster_name, resource_group_name, update=False, space_name=None, prompt=False):
def ads_use_dev_spaces(cluster_name, resource_group_name, update=False, space_name=None, do_not_prompt=False):
"""
Use Azure Dev Spaces with a managed Kubernetes cluster.

Expand All @@ -31,39 +31,26 @@ def ads_use_dev_spaces(cluster_name, resource_group_name, update=False, space_na
:type update: bool
:param space_name: Name of the new or existing dev space to select. Defaults to an interactive selection experience.
:type space_name: String
:param prompt: Do not prompt for confirmation. Requires --space.
:type prompt: bool
:param do_not_prompt: Do not prompt for confirmation. Requires --space.
:type do_not_prompt: bool
"""

azds_cli = _install_dev_spaces_cli(update)

from subprocess import PIPE
retCode = subprocess.call(
[azds_cli, 'controller', 'select', '--name', cluster_name, '--resource-group', resource_group_name],
stderr=PIPE)
if retCode != 0:
retCode = subprocess.call(
[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:
return

if space_name is None:
space_name = 'default'

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 prompt:
pass
subprocess.call(create_space_arguments, universal_newlines=True)


def ads_remove_dev_spaces(cluster_name, resource_group_name, prompt=False):
use_command_arguments = [azds_cli, 'use', '--name', cluster_name,
'--resource-group', resource_group_name]

if space_name is not None:
use_command_arguments.append('--space')
use_command_arguments.append(space_name)

if do_not_prompt:
use_command_arguments.append('-y')
subprocess.call(
use_command_arguments, universal_newlines=True)


def ads_remove_dev_spaces(cluster_name, resource_group_name, do_not_prompt=False):
"""
Remove Azure Dev Spaces from a managed Kubernetes cluster.

Expand All @@ -72,15 +59,15 @@ def ads_remove_dev_spaces(cluster_name, resource_group_name, prompt=False):
:param resource_group_name: Name of resource group. You can configure the default group. \
Using 'az configure --defaults group=<name>'.
:type resource_group_name: String
:param prompt: Do not prompt for confirmation.
:type prompt: bool
:param do_not_prompt: Do not prompt for confirmation.
:type do_not_prompt: bool
"""

azds_cli = _install_dev_spaces_cli(False)

remove_command_arguments = [azds_cli, 'controller', 'delete', '--name',
cluster_name, '--resource-group', resource_group_name]
if prompt:
remove_command_arguments = [azds_cli, 'remove', '--name', cluster_name,
'--resource-group', resource_group_name]
if do_not_prompt:
remove_command_arguments.append('-y')
subprocess.call(
remove_command_arguments, universal_newlines=True)
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.4"
VERSION = "0.1.5"

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 @@ -370,9 +370,9 @@
],
"dev-spaces-preview": [
{
"filename": "dev_spaces_preview-0.1.4-py2.py3-none-any.whl",
"sha256Digest": "cd2d50ea8a3a46a4b86d3a8810341b05205b91d87b8e9e5c26e7536714bad7ff",
"downloadUrl": "https://azuredevspacestools.blob.core.windows.net/azdssetup/LKS/dev_spaces_preview-0.1.4-py2.py3-none-any.whl",
"filename": "dev_spaces_preview-0.1.5-py2.py3-none-any.whl",
"sha256Digest": "28077ae576f5a86dca30f7def0308d3a26d7464f91f82109c1dc8fc4b11c6a6f",
"downloadUrl": "https://azuredevspacestools.blob.core.windows.net/azdssetup/LKS/dev_spaces_preview-0.1.5-py2.py3-none-any.whl",
"metadata": {
"azext.isPreview": true,
"azext.minCliCoreVersion": "2.0.32",
Expand Down Expand Up @@ -411,7 +411,7 @@
"metadata_version": "2.0",
"name": "dev-spaces-preview",
"summary": "Dev Spaces provides a rapid, iterative Kubernetes development experience for teams.",
"version": "0.1.4"
"version": "0.1.5"
}
}
],
Expand Down