From 2239d64d3ecbd2b7d626205393bc71737b4a85e5 Mon Sep 17 00:00:00 2001 From: Ruoyu Wang Date: Mon, 9 Jan 2023 14:16:29 +0800 Subject: [PATCH 1/6] add --deployment-name for app create --- src/spring/HISTORY.md | 4 ++++ src/spring/azext_spring/_params.py | 2 ++ src/spring/azext_spring/app.py | 6 ++++-- src/spring/azext_spring/tests/latest/test_asa_app.py | 7 ++++++- src/spring/setup.py | 2 +- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/spring/HISTORY.md b/src/spring/HISTORY.md index a9f50055049..d59ea8efda1 100644 --- a/src/spring/HISTORY.md +++ b/src/spring/HISTORY.md @@ -1,5 +1,9 @@ Release History =============== +1.7.0 +--- +* Add argument `--deployment-name` in command `az spring app create`. + 1.6.1 --- * Add type check for argument `--artifact-path`. diff --git a/src/spring/azext_spring/_params.py b/src/spring/azext_spring/_params.py index 5ef27ce22a7..0c87b43ac53 100644 --- a/src/spring/azext_spring/_params.py +++ b/src/spring/azext_spring/_params.py @@ -268,6 +268,8 @@ def load_arguments(self, _): help='A json file path for the persistent storages to be mounted to the app') c.argument('loaded_public_certificate_file', options_list=['--loaded-public-certificate-file', '-f'], type=str, help='A json file path indicates the certificates which would be loaded to app') + c.argument('deployment_name', type=str, + help='Name of the active deployment. Deployment named "default" will be created if this argument not provided', validator=validate_name) with self.argument_context('spring app update') as c: c.argument('assign_endpoint', arg_type=get_three_state_flag(), diff --git a/src/spring/azext_spring/app.py b/src/spring/azext_spring/app.py index 54841ef88f6..8ffa36da658 100644 --- a/src/spring/azext_spring/app.py +++ b/src/spring/azext_spring/app.py @@ -35,6 +35,7 @@ def app_create(cmd, client, resource_group, service, name, + deployment_name=None, # deployment.settings cpu=None, memory=None, @@ -143,12 +144,13 @@ def app_create(cmd, client, resource_group, service, name, app_poller = client.apps.begin_create_or_update(resource_group, service, name, app_resource) wait_till_end(cmd, app_poller) - logger.warning('[2/3] Creating default deployment with name "{}"'.format(DEFAULT_DEPLOYMENT_NAME)) + banner_deployment_name=deployment_name or DEFAULT_DEPLOYMENT_NAME + logger.warning('[2/3] Creating default deployment with name "{}"'.format(banner_deployment_name)) deployment_resource = deployment_factory.format_resource(**create_deployment_kwargs, **basic_kwargs) poller = client.deployments.begin_create_or_update(resource_group, service, name, - DEFAULT_DEPLOYMENT_NAME, + banner_deployment_name, deployment_resource) logger.warning('[3/3] Updating app "{}" (this operation can take a while to complete)'.format(name)) app_resource = app_factory.format_resource(**update_app_kwargs, **basic_kwargs) diff --git a/src/spring/azext_spring/tests/latest/test_asa_app.py b/src/spring/azext_spring/tests/latest/test_asa_app.py index 3e951fe16cc..1ee522e2103 100644 --- a/src/spring/azext_spring/tests/latest/test_asa_app.py +++ b/src/spring/azext_spring/tests/latest/test_asa_app.py @@ -598,8 +598,8 @@ def _execute(self, *args, **kwargs): call_args = client.deployments.begin_create_or_update.call_args_list self.assertEqual(1, len(call_args)) self.assertEqual(5, len(call_args[0][0])) - self.assertEqual(args[0:3] + ('default',), call_args[0][0][0:4]) self.put_deployment_resource = call_args[0][0][4] + self.put_deployment_resource.name = call_args[0][0][3] call_args = client.apps.begin_update.call_args_list self.assertEqual(1, len(call_args)) @@ -693,6 +693,11 @@ def test_app_with_client_auth(self): resource = self.patch_app_resource self.assertIsNone(resource.properties.ingress_settings) + def test_app_create_with_deployment_name(self): + self._execute('rg', 'asc', 'app', cpu='1', memory='1Gi', instance_count=1, deployment_name='hello') + resource = self.put_deployment_resource + self.assertEqual('hello', resource.name) + class TestDeploymentCreate(BasicTest): def __init__(self, methodName: str = ...): super().__init__(methodName=methodName) diff --git a/src/spring/setup.py b/src/spring/setup.py index 8bebba91895..d2ab6375d8f 100644 --- a/src/spring/setup.py +++ b/src/spring/setup.py @@ -16,7 +16,7 @@ # TODO: Confirm this is the right version number you want and it matches your # HISTORY.rst entry. -VERSION = '1.6.1' +VERSION = '1.7.0' # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers From ad574e500815f501cbe733bcae0a7397759809f4 Mon Sep 17 00:00:00 2001 From: Ruoyu Wang Date: Mon, 9 Jan 2023 17:25:59 +0800 Subject: [PATCH 2/6] fix help text --- src/spring/azext_spring/_params.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/spring/azext_spring/_params.py b/src/spring/azext_spring/_params.py index 0c87b43ac53..6ed01b70182 100644 --- a/src/spring/azext_spring/_params.py +++ b/src/spring/azext_spring/_params.py @@ -268,8 +268,8 @@ def load_arguments(self, _): help='A json file path for the persistent storages to be mounted to the app') c.argument('loaded_public_certificate_file', options_list=['--loaded-public-certificate-file', '-f'], type=str, help='A json file path indicates the certificates which would be loaded to app') - c.argument('deployment_name', type=str, - help='Name of the active deployment. Deployment named "default" will be created if this argument not provided', validator=validate_name) + c.argument('deployment_name', type=str, default='default', + help='Name of the active deployment.', validator=validate_name) with self.argument_context('spring app update') as c: c.argument('assign_endpoint', arg_type=get_three_state_flag(), From 61e689ddfffcd45723682533647ff0d32eda30f2 Mon Sep 17 00:00:00 2001 From: Ruoyu Wang Date: Mon, 9 Jan 2023 17:43:46 +0800 Subject: [PATCH 3/6] fix help text for deployment_name --- src/spring/azext_spring/_params.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spring/azext_spring/_params.py b/src/spring/azext_spring/_params.py index 6ed01b70182..cc3e09f9f54 100644 --- a/src/spring/azext_spring/_params.py +++ b/src/spring/azext_spring/_params.py @@ -269,7 +269,7 @@ def load_arguments(self, _): c.argument('loaded_public_certificate_file', options_list=['--loaded-public-certificate-file', '-f'], type=str, help='A json file path indicates the certificates which would be loaded to app') c.argument('deployment_name', type=str, default='default', - help='Name of the active deployment.', validator=validate_name) + help='Name of the default deployment.', validator=validate_name) with self.argument_context('spring app update') as c: c.argument('assign_endpoint', arg_type=get_three_state_flag(), From be058df9fec582734a8d2100c4caac1414c54d5e Mon Sep 17 00:00:00 2001 From: Ruoyu Wang Date: Tue, 10 Jan 2023 13:27:54 +0800 Subject: [PATCH 4/6] fix comments --- src/spring/HISTORY.md | 2 +- src/spring/azext_spring/_params.py | 2 +- src/spring/setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/spring/HISTORY.md b/src/spring/HISTORY.md index 85921b8584a..3f9d31e9afc 100644 --- a/src/spring/HISTORY.md +++ b/src/spring/HISTORY.md @@ -1,6 +1,6 @@ Release History =============== -1.7.0 +1.6.4 --- * Add argument `--deployment-name` in command `az spring app create`. diff --git a/src/spring/azext_spring/_params.py b/src/spring/azext_spring/_params.py index 8da16a5b4b9..c2848bd0d6a 100644 --- a/src/spring/azext_spring/_params.py +++ b/src/spring/azext_spring/_params.py @@ -267,7 +267,7 @@ def load_arguments(self, _): help='A json file path for the persistent storages to be mounted to the app') c.argument('loaded_public_certificate_file', options_list=['--loaded-public-certificate-file', '-f'], type=str, help='A json file path indicates the certificates which would be loaded to app') - c.argument('deployment_name', type=str, default='default', + c.argument('deployment_name', default='default', help='Name of the default deployment.', validator=validate_name) with self.argument_context('spring app update') as c: diff --git a/src/spring/setup.py b/src/spring/setup.py index d2ab6375d8f..5e610ff902b 100644 --- a/src/spring/setup.py +++ b/src/spring/setup.py @@ -16,7 +16,7 @@ # TODO: Confirm this is the right version number you want and it matches your # HISTORY.rst entry. -VERSION = '1.7.0' +VERSION = '1.6.4' # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers From b5cf33c4fb0fa93d871ba0ef3dadc40b2c5654cf Mon Sep 17 00:00:00 2001 From: Ruoyu Wang Date: Wed, 11 Jan 2023 14:41:20 +0800 Subject: [PATCH 5/6] remove line feed --- src/spring/HISTORY.md | 1 - 1 file changed, 1 deletion(-) diff --git a/src/spring/HISTORY.md b/src/spring/HISTORY.md index b7cd75e18bf..42bc7898935 100644 --- a/src/spring/HISTORY.md +++ b/src/spring/HISTORY.md @@ -11,7 +11,6 @@ Release History * Add new commands `az spring gateway create` and `az spring gateway delete`. * Add new commands `az spring api-portal create` and `az spring api-portal delete`. - 1.6.3 --- * Deprecate the subcommand 'spring app binding'. From 44a03e361f96f5896c18244b84c4f352ea71a156 Mon Sep 17 00:00:00 2001 From: Ruoyu Wang Date: Tue, 31 Jan 2023 11:23:17 +0800 Subject: [PATCH 6/6] fix format --- src/spring/azext_spring/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spring/azext_spring/app.py b/src/spring/azext_spring/app.py index 8ffa36da658..ec9b97732ca 100644 --- a/src/spring/azext_spring/app.py +++ b/src/spring/azext_spring/app.py @@ -144,7 +144,7 @@ def app_create(cmd, client, resource_group, service, name, app_poller = client.apps.begin_create_or_update(resource_group, service, name, app_resource) wait_till_end(cmd, app_poller) - banner_deployment_name=deployment_name or DEFAULT_DEPLOYMENT_NAME + banner_deployment_name = deployment_name or DEFAULT_DEPLOYMENT_NAME logger.warning('[2/3] Creating default deployment with name "{}"'.format(banner_deployment_name)) deployment_resource = deployment_factory.format_resource(**create_deployment_kwargs, **basic_kwargs) poller = client.deployments.begin_create_or_update(resource_group,