Skip to content

Commit 7968fe0

Browse files
authored
[Spring-Cloud] Enable deployment input for az spring-cloud app logs (Azure#2753)
1 parent 8bc446f commit 7968fe0

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

src/spring-cloud/HISTORY.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Release History
22
===============
3+
2.1.2
4+
-----
5+
* Add optional '--deployment' to 'az spring-cloud app logs' command
6+
37
2.1.1
48
-----
59
* Remove preview parameter '--enable-java-agent' from 'az spring-cloud update'.

src/spring-cloud/azext_spring_cloud/_params.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,17 @@ def load_arguments(self, _):
106106
c.argument('follow', options_list=['--follow ', '-f'], help='Specify if the logs should be streamed.', action='store_true')
107107
c.argument('since', help='Only return logs newer than a relative duration like 5s, 2m, or 1h. Maximum is 1h', validator=validate_log_since)
108108
c.argument('limit', type=int, help='Maximum kilobytes of logs to return. Ceiling number is 2048.', validator=validate_log_limit)
109+
c.argument('deployment', options_list=[
110+
'--deployment', '-d'], help='Name of an existing deployment of the app. Default to the production deployment if not specified.', validator=validate_deployment_name)
109111

110112
with self.argument_context('spring-cloud app log tail') as c:
111113
c.argument('instance', options_list=['--instance', '-i'], help='Name of an existing instance of the deployment.')
112114
c.argument('lines', type=int, help='Number of lines to show. Maximum is 10000', validator=validate_log_lines)
113115
c.argument('follow', options_list=['--follow ', '-f'], help='Specify if the logs should be streamed.', action='store_true')
114116
c.argument('since', help='Only return logs newer than a relative duration like 5s, 2m, or 1h. Maximum is 1h', validator=validate_log_since)
115117
c.argument('limit', type=int, help='Maximum kilobytes of logs to return. Ceiling number is 2048.', validator=validate_log_limit)
118+
c.argument('deployment', options_list=[
119+
'--deployment', '-d'], help='Name of an existing deployment of the app. Default to the production deployment if not specified.', validator=validate_deployment_name)
116120

117121
with self.argument_context('spring-cloud app set-deployment') as c:
118122
c.argument('deployment', options_list=[

src/spring-cloud/azext_spring_cloud/custom.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -529,21 +529,21 @@ def app_get_build_log(cmd, client, resource_group, service, name, deployment=Non
529529
return stream_logs(client.deployments, resource_group, service, name, deployment)
530530

531531

532-
def app_tail_log(cmd, client, resource_group, service, name, instance=None, follow=False, lines=50, since=None, limit=2048):
532+
def app_tail_log(cmd, client, resource_group, service, name, deployment=None, instance=None, follow=False, lines=50, since=None, limit=2048):
533533
if not instance:
534-
deployment_name = client.apps.get(
535-
resource_group, service, name).properties.active_deployment_name
536-
if not deployment_name:
537-
raise CLIError(
538-
"No production deployment found for app '{}'".format(name))
539-
deployment = client.deployments.get(
540-
resource_group, service, name, deployment_name)
541-
if not deployment.properties.instances:
534+
if deployment is None:
535+
deployment = client.apps.get(
536+
resource_group, service, name).properties.active_deployment_name
537+
if not deployment:
538+
raise CLIError(NO_PRODUCTION_DEPLOYMENT_ERROR)
539+
deployment_properties = client.deployments.get(
540+
resource_group, service, name, deployment).properties
541+
if not deployment_properties.instances:
542542
raise CLIError("No instances found for deployment '{0}' in app '{1}'".format(
543-
deployment_name, name))
544-
instances = deployment.properties.instances
543+
deployment, name))
544+
instances = deployment_properties.instances
545545
if len(instances) > 1:
546-
logger.warning("Mulitple app instances found:")
546+
logger.warning("Multiple app instances found:")
547547
for temp_instance in instances:
548548
logger.warning("{}".format(temp_instance.name))
549549
logger.warning("Please use '-i/--instance' parameter to specify the instance name")

0 commit comments

Comments
 (0)