-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
[ACR] Add new commands az acr taskrun show/list/delete
for show list and remove
#11858
Changes from 20 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 |
---|---|---|
|
@@ -894,6 +894,48 @@ | |
az acr task update-run -r MyRegistry --run-id runId --no-archive false | ||
""" | ||
|
||
helps['acr taskrun'] = """ | ||
type: group | ||
short-summary: Manage taskruns using Azure Container Registries. | ||
""" | ||
|
||
|
||
helps['acr taskrun delete'] = """ | ||
type: command | ||
short-summary: Delete a taskrun from an Azure Container Registry. | ||
examples: | ||
- name: Delete a taskrun from an Azure Container Registry. | ||
text: > | ||
az acr taskrun delete -r MyRegistry -n MyTaskRun -g MyResourceGroup | ||
""" | ||
|
||
helps['acr taskrun list'] = """ | ||
type: command | ||
short-summary: List the taskruns for an Azure Container Registry. | ||
examples: | ||
- name: List taskruns and show the results in a table. | ||
text: > | ||
az acr taskrun list -r MyRegistry -g MyResourceGroup -o table | ||
""" | ||
|
||
helps['acr taskrun show'] = """ | ||
type: command | ||
short-summary: Get the properties of a named taskrun for an Azure Container Registry. | ||
examples: | ||
- name: Get the properties of a taskrun, displaying the results in a table. | ||
text: > | ||
az acr taskrun show -r MyRegistry -n MyTaskRun -o table | ||
""" | ||
|
||
helps['acr taskrun logs'] = """ | ||
type: command | ||
short-summary: Show logs for a particular run. | ||
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. taskrun |
||
examples: | ||
- name: Show logs for a particular run. | ||
text: > | ||
az acr taskrun logs -r MyRegistry --run-id runId | ||
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. should it accept |
||
""" | ||
|
||
helps['acr token'] = """ | ||
type: group | ||
short-summary: Manage tokens for an Azure Container Registry. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,8 @@ | |
REGISTRY_RESOURCE_TYPE, | ||
WEBHOOK_RESOURCE_TYPE, | ||
REPLICATION_RESOURCE_TYPE, | ||
TASK_RESOURCE_TYPE | ||
TASK_RESOURCE_TYPE, | ||
TASKRUN_RESOURCE_TYPE | ||
) | ||
from ._validators import ( | ||
validate_headers, | ||
|
@@ -236,6 +237,11 @@ def load_arguments(self, _): # pylint: disable=too-many-statements | |
c.argument('timer_schedule', options_list=['--schedule'], help="The schedule of the timer trigger represented as a cron expression.") | ||
c.argument('enabled', help="Indicates whether the timer trigger is enabled.", arg_type=get_three_state_flag()) | ||
|
||
with self.argument_context('acr taskrun') as c: | ||
c.argument('registry_name', options_list=['--registry', '-r']) | ||
c.argument('run_id', help='The unique run identifier.') | ||
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 taskrun logs take taskrun name, I assume you don't need run_id argument. |
||
c.argument('taskrun_name', options_list=['--name', '-n'], help='The name of the taskrun.', completer=get_resource_name_completion_list(TASKRUN_RESOURCE_TYPE)) | ||
|
||
with self.argument_context('acr helm') as c: | ||
c.argument('resource_group_name', deprecate_info=c.deprecate(hide=True)) | ||
c.argument('repository', help=argparse.SUPPRESS) | ||
|
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') | ||
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. It just occurs to me if we can introduce |
||
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,56 @@ | ||
# -------------------------------------------------------------------------------------------- | ||
# 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( | ||
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. can we use validator for you command or argument https://github.com/Azure/azure-cli/blob/dev/doc/authoring_command_modules/authoring_commands.md#validators? 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. @Juliehzl current |
||
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, | ||
run_id=None, | ||
resource_group_name=None): | ||
_, resource_group_name = validate_managed_registry( | ||
cmd, registry_name, resource_group_name, TASKRUN_NOT_SUPPORTED) | ||
return stream_logs(client, run_id, registry_name, resource_group_name) | ||
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
startTime
andfinishTime
of 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.