From 1f1fe8755efd0a638f60bf258e2ec64a66d8b09f Mon Sep 17 00:00:00 2001 From: Rakesh Reddy Vanga Date: Mon, 3 Feb 2020 17:38:00 -0800 Subject: [PATCH 1/4] adding endpoint type option for dev spaces command --- .vscode/launch.json | 4 +++- src/azure-cli/azure/cli/command_modules/acs/_help.py | 12 ++++++++++-- .../azure/cli/command_modules/acs/_params.py | 3 +++ .../azure/cli/command_modules/acs/custom.py | 7 +++++-- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index a3bb8f78c2a..290eaf0762d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -28,7 +28,9 @@ "program": "${workspaceRoot}/src/azure-cli/azure/cli/__main__.py", "cwd": "${workspaceRoot}", "args": [ - "--help" + "aks", + "use-dev-spaces", + "-n", "rareddyv-private", "-g" , "rareddyv-private" ], "console": "externalTerminal", "debugOptions": [ diff --git a/src/azure-cli/azure/cli/command_modules/acs/_help.py b/src/azure-cli/azure/cli/command_modules/acs/_help.py index db8a24447d1..8773437bb95 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/_help.py +++ b/src/azure-cli/azure/cli/command_modules/acs/_help.py @@ -829,16 +829,24 @@ - name: --space -s type: string short-summary: Name of the new or existing dev space to select. Defaults to an interactive selection experience. + - name: --endpoint -e + type: string + short-summary: The endpoint type to be used for a Azure Dev Spaces controller. See https://aka.ms/azds-networking for more information. examples: - name: Use Azure Dev Spaces with a managed Kubernetes cluster, interactively selecting a dev space. text: |- az aks use-dev-spaces -g my-aks-group -n my-aks - - name: Use Azure Dev Spaces with a managed Kubernetes cluster, updating to the latest Azure Dev Spaces \\ client components and selecting a new or existing dev space 'my-space'. + - name: Use Azure Dev Spaces with a managed Kubernetes cluster, updating to the latest Azure Dev Spaces \ + client components and selecting a new or existing dev space 'my-space'. text: |- az aks use-dev-spaces -g my-aks-group -n my-aks --update --space my-space - - name: Use Azure Dev Spaces with a managed Kubernetes cluster, selecting a new or existing dev space \\ 'develop/my-space' without prompting for confirmation. + - name: Use Azure Dev Spaces with a managed Kubernetes cluster, selecting a new or existing dev space \ + 'develop/my-space' without prompting for confirmation. text: |- az aks use-dev-spaces -g my-aks-group -n my-aks -s develop/my-space -y + - name: Use Azure Dev Spaces with a managed Kubernetes cluster with a private endpoint. + text: |- + az aks use-dev-spaces -g my-aks-group -n my-aks -e private """ helps['aks wait'] = """ diff --git a/src/azure-cli/azure/cli/command_modules/acs/_params.py b/src/azure-cli/azure/cli/command_modules/acs/_params.py index 2938d184ce0..0df396d41d7 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/_params.py +++ b/src/azure-cli/azure/cli/command_modules/acs/_params.py @@ -24,6 +24,8 @@ aci_connector_os_type = ['Windows', 'Linux', 'Both'] +dev_spaces_endpoint_type = ['Public', 'Private', 'None'] + aci_connector_chart_url = 'https://github.com/virtual-kubelet/virtual-kubelet/raw/master/charts/virtual-kubelet-for-aks-latest.tgz' orchestrator_types = ["Custom", "DCOS", "Kubernetes", "Swarm", "DockerCE"] @@ -303,6 +305,7 @@ def load_arguments(self, _): with self.argument_context('aks use-dev-spaces') as c: c.argument('update', options_list=['--update'], action='store_true') c.argument('space_name', options_list=['--space', '-s']) + c.argument('endpoint_type', get_enum_type(dev_spaces_endpoint_type, default='Public'), options_list=['--endpoint', '-e']) c.argument('prompt', options_list=['--yes', '-y'], action='store_true', help='Do not prompt for confirmation. Requires --space.') with self.argument_context('aks remove-dev-spaces') as c: diff --git a/src/azure-cli/azure/cli/command_modules/acs/custom.py b/src/azure-cli/azure/cli/command_modules/acs/custom.py index f73b4b3e6ed..6ba01548e81 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/custom.py +++ b/src/azure-cli/azure/cli/command_modules/acs/custom.py @@ -2120,7 +2120,7 @@ def aks_upgrade(cmd, client, resource_group_name, name, kubernetes_version, cont DEV_SPACES_EXTENSION_MODULE = 'azext_dev_spaces.custom' -def aks_use_dev_spaces(cmd, client, name, resource_group_name, update=False, space_name=None, prompt=False): +def aks_use_dev_spaces(cmd, client, name, resource_group_name, update=False, space_name=None, endpoint_type=None, prompt=False): """ Use Azure Dev Spaces with a managed Kubernetes cluster. @@ -2133,6 +2133,9 @@ def aks_use_dev_spaces(cmd, client, name, resource_group_name, update=False, spa :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 endpoint_type: The endpoint type to be used for a Azure Dev Spaces controller. \ + See https://aka.ms/azds-networking for more information. + :type endpoint_type: String :param prompt: Do not prompt for confirmation. Requires --space. :type prompt: bool """ @@ -2140,7 +2143,7 @@ def aks_use_dev_spaces(cmd, client, name, resource_group_name, update=False, spa if _get_or_add_extension(cmd, DEV_SPACES_EXTENSION_NAME, DEV_SPACES_EXTENSION_MODULE, update): azext_custom = _get_azext_module(DEV_SPACES_EXTENSION_NAME, DEV_SPACES_EXTENSION_MODULE) try: - azext_custom.ads_use_dev_spaces(name, resource_group_name, update, space_name, prompt) + azext_custom.ads_use_dev_spaces(name, resource_group_name, update, space_name, endpoint_type, prompt) except TypeError: raise CLIError("Use '--update' option to get the latest Azure Dev Spaces client components.") except AttributeError as ae: From e8c122f18f504e751814f7887a5050e497b4518d Mon Sep 17 00:00:00 2001 From: Rakesh Reddy Vanga Date: Mon, 3 Feb 2020 17:38:30 -0800 Subject: [PATCH 2/4] revert the changes for launh.json file --- .vscode/launch.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 290eaf0762d..a3bb8f78c2a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -28,9 +28,7 @@ "program": "${workspaceRoot}/src/azure-cli/azure/cli/__main__.py", "cwd": "${workspaceRoot}", "args": [ - "aks", - "use-dev-spaces", - "-n", "rareddyv-private", "-g" , "rareddyv-private" + "--help" ], "console": "externalTerminal", "debugOptions": [ From b233df3e96b0e0254763bdca5137d3d59fea3c92 Mon Sep 17 00:00:00 2001 From: Rakesh Reddy Vanga Date: Tue, 4 Feb 2020 15:21:59 -0800 Subject: [PATCH 3/4] fixed linter errors/warnings --- src/azure-cli/azure/cli/command_modules/acs/custom.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/acs/custom.py b/src/azure-cli/azure/cli/command_modules/acs/custom.py index 6ba01548e81..9c207a4ce42 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/custom.py +++ b/src/azure-cli/azure/cli/command_modules/acs/custom.py @@ -2120,7 +2120,8 @@ def aks_upgrade(cmd, client, resource_group_name, name, kubernetes_version, cont DEV_SPACES_EXTENSION_MODULE = 'azext_dev_spaces.custom' -def aks_use_dev_spaces(cmd, client, name, resource_group_name, update=False, space_name=None, endpoint_type=None, prompt=False): +def aks_use_dev_spaces(cmd, client, name, resource_group_name, update=False, space_name=None, + endpoint_type='Public', prompt=False): """ Use Azure Dev Spaces with a managed Kubernetes cluster. @@ -2131,7 +2132,8 @@ def aks_use_dev_spaces(cmd, client, name, resource_group_name, update=False, spa :type resource_group_name: String :param update: Update to the latest Azure Dev Spaces client components. :type update: bool - :param space_name: Name of the new or existing dev space to select. Defaults to an interactive selection experience. + :param space_name: Name of the new or existing dev space to select. Defaults to an \ + interactive selection experience. :type space_name: String :param endpoint_type: The endpoint type to be used for a Azure Dev Spaces controller. \ See https://aka.ms/azds-networking for more information. From 029b32e338ab4b815b1faf314f081880a97f1d14 Mon Sep 17 00:00:00 2001 From: Rakesh Reddy Vanga Date: Thu, 6 Feb 2020 20:17:17 -0800 Subject: [PATCH 4/4] Using inplace list for endpointType --- src/azure-cli/azure/cli/command_modules/acs/_params.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/acs/_params.py b/src/azure-cli/azure/cli/command_modules/acs/_params.py index 0df396d41d7..23623f0cf58 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/_params.py +++ b/src/azure-cli/azure/cli/command_modules/acs/_params.py @@ -24,8 +24,6 @@ aci_connector_os_type = ['Windows', 'Linux', 'Both'] -dev_spaces_endpoint_type = ['Public', 'Private', 'None'] - aci_connector_chart_url = 'https://github.com/virtual-kubelet/virtual-kubelet/raw/master/charts/virtual-kubelet-for-aks-latest.tgz' orchestrator_types = ["Custom", "DCOS", "Kubernetes", "Swarm", "DockerCE"] @@ -305,7 +303,7 @@ def load_arguments(self, _): with self.argument_context('aks use-dev-spaces') as c: c.argument('update', options_list=['--update'], action='store_true') c.argument('space_name', options_list=['--space', '-s']) - c.argument('endpoint_type', get_enum_type(dev_spaces_endpoint_type, default='Public'), options_list=['--endpoint', '-e']) + c.argument('endpoint_type', get_enum_type(['Public', 'Private', 'None'], default='Public'), options_list=['--endpoint', '-e']) c.argument('prompt', options_list=['--yes', '-y'], action='store_true', help='Do not prompt for confirmation. Requires --space.') with self.argument_context('aks remove-dev-spaces') as c: