-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[ACR] Add new commands az acr taskrun show/list/delete for show list and remove
#11858
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
Changes from all commits
089c62e
5e21545
ab64ea0
dbb10b5
55957bf
5aa473f
74f4618
961c895
72b7d80
f019cc2
723c056
f100e1b
3dc0fae
ec34523
f5b8bda
99cd4ad
365ee98
091182e
bddd06d
e1f5f2c
f37316a
30a14ea
5629f40
d05154b
a9f1a70
37a6d54
f958caa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ | |
| replication_output_format, | ||
| build_output_format, | ||
| task_output_format, | ||
| taskrun_output_format, | ||
| run_output_format, | ||
| helm_list_output_format, | ||
| helm_show_output_format, | ||
|
|
@@ -29,6 +30,7 @@ | |
| cf_acr_replications, | ||
| cf_acr_webhooks, | ||
| cf_acr_tasks, | ||
| cf_acr_taskruns, | ||
| cf_acr_runs, | ||
| cf_acr_scope_maps, | ||
| cf_acr_tokens, | ||
|
|
@@ -105,6 +107,12 @@ def load_command_table(self, _): # pylint: disable=too-many-statements | |
| client_factory=cf_acr_tasks | ||
| ) | ||
|
|
||
| acr_taskrun_util = CliCommandType( | ||
| operations_tmpl='azure.cli.command_modules.acr.taskrun#{}', | ||
| table_transformer=taskrun_output_format, | ||
| client_factory=cf_acr_taskruns | ||
| ) | ||
|
|
||
| acr_helm_util = CliCommandType( | ||
| operations_tmpl='azure.cli.command_modules.acr.helm#{}' | ||
| ) | ||
|
|
@@ -237,6 +245,13 @@ def load_command_table(self, _): # pylint: disable=too-many-statements | |
| g.command('logs', 'acr_task_logs', client_factory=cf_acr_runs, | ||
| table_transformer=None) | ||
|
|
||
| with self.command_group('acr taskrun', acr_taskrun_util, is_preview=True) as g: | ||
| g.command('list', 'acr_taskrun_list') | ||
| g.command('delete', 'acr_taskrun_delete') | ||
| g.command('show', 'acr_taskrun_show') | ||
|
||
| g.command('logs', 'acr_taskrun_logs', client_factory=cf_acr_runs, | ||
| table_transformer=None) | ||
|
|
||
| with self.command_group('acr config content-trust', acr_policy_util) as g: | ||
| g.command('show', 'acr_config_content_trust_show') | ||
| g.command('update', 'acr_config_content_trust_update') | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| from ._stream_utils import stream_logs | ||
| from ._utils import ( | ||
| user_confirmation, | ||
| validate_managed_registry | ||
| ) | ||
|
|
||
|
|
||
| TASKRUN_NOT_SUPPORTED = 'TaskRun is only supported for managed registries.' | ||
|
|
||
|
|
||
| def acr_taskrun_show(cmd, | ||
| client, | ||
| taskrun_name, | ||
| registry_name, | ||
| resource_group_name=None): | ||
| _, resource_group_name = validate_managed_registry( | ||
|
||
| cmd, registry_name, resource_group_name, TASKRUN_NOT_SUPPORTED) | ||
| return client.get(resource_group_name, registry_name, taskrun_name) | ||
|
|
||
|
|
||
| def acr_taskrun_list(cmd, | ||
| client, | ||
| registry_name, | ||
| resource_group_name=None): | ||
|
|
||
| _, resource_group_name = validate_managed_registry( | ||
| cmd, registry_name, resource_group_name, TASKRUN_NOT_SUPPORTED) | ||
| return client.list(resource_group_name, registry_name) | ||
|
|
||
|
|
||
| def acr_taskrun_delete(cmd, | ||
| client, | ||
| taskrun_name, | ||
| registry_name, | ||
| resource_group_name=None, | ||
| yes=False): | ||
| _, resource_group_name = validate_managed_registry( | ||
| cmd, registry_name, resource_group_name, TASKRUN_NOT_SUPPORTED) | ||
|
|
||
| user_confirmation("Are you sure you want to delete the taskrun '{}' ".format(taskrun_name), yes) | ||
| return client.delete(resource_group_name, registry_name, taskrun_name) | ||
|
|
||
|
|
||
| def acr_taskrun_logs(cmd, | ||
| client, # cf_acr_runs | ||
| registry_name, | ||
| taskrun_name, | ||
| resource_group_name=None): | ||
| _, resource_group_name = validate_managed_registry( | ||
| cmd, registry_name, resource_group_name, TASKRUN_NOT_SUPPORTED) | ||
|
|
||
| from ._client_factory import cf_acr_taskruns | ||
| client_taskruns = cf_acr_taskruns(cmd.cli_ctx) | ||
| response = client_taskruns.get(resource_group_name, registry_name, taskrun_name) | ||
| run_id = response.run_result.run_id | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a possibility that
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the run not finish, there's no taskrun record. If anything wrong, RP will throw the error. |
||
|
|
||
| return stream_logs(client, run_id, registry_name, resource_group_name) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The function needs to take the taskrun name, get the runid using the name and stream the log using the run id. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@huanwu some other properties to add similar to the standard run output would be 'RUN ID', 'STARTED', AND 'DURATION'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how do we know if run has started?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The taskrun deployment won't return if run not finish. But for show/list/delete method, why do we care if run started or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duration might be a good thing to support in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaysterp @shahzzzam Thanks! Updated the output and added a test to cover all the commands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shahzzzam @huanwu duration is caluculated from the
startTimeandfinishTimeof the completed task run, see how we calculate this for our current run output run. These sort of metrics may be useful to customers so that they can track when a task was run and how long that run took to finish. Also has continuity with our current output format for runs.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jaysterp @shahzzzam Yes, the duration was added in the format calculated from startTime and finishTime.