Skip to content

Commit

Permalink
Add acr taskrun logs command. Fix several things based on PR comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
huanwu committed Jan 22, 2020
1 parent 3dc0fae commit ec34523
Show file tree
Hide file tree
Showing 10 changed files with 616 additions and 230 deletions.
6 changes: 2 additions & 4 deletions src/azure-cli/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Release History
**ACR**

* [BREAKING CHANGE] `az acr delete` will prompt
* [BREAKING CHANGE] 'az acr task delete' will prompt
* Add new command 'az acr taskrun show/list/delete' to show, list, delete the taskrun

**AppConfig**

Expand Down Expand Up @@ -49,10 +51,6 @@ Release History
* `az storage remove`: Change `--inlcude` and `--exclude` parameters to `--include-path`, `--include-pattern`, `--exclude-path` and`--exclude-pattern` parameters
* `az storage sync`: Add `--include-pattern`, `--exclude-path` and`--exclude-pattern` parameters

**ACR**

* Add new command 'az acr taskrun show/list/delete' to show, list, delete the taskrun

2.0.80
++++++

Expand Down
3 changes: 0 additions & 3 deletions src/azure-cli/azure/cli/command_modules/acr/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,6 @@ def _taskrun_format_group(item):
('TASK', _get_value(item, 'task')),
('PLATFORM', _get_value(item, 'platform', 'os')),
('STATUS', _get_value(item, 'status')),
("TRIGGER", _get_build_trigger(_get_value(item, 'imageUpdateTrigger'),
_get_value(item, 'sourceTrigger', 'eventType'),
_get_value(item, 'timerTrigger'))),
('STARTED', _format_datetime(_get_value(item, 'startTime'))),
('DURATION', _get_duration(_get_value(item, 'startTime'), _get_value(item, 'finishTime')))
])
Expand Down
9 changes: 9 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acr/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,15 @@
az acr taskrun show -r MyRegistry -n MyTaskRun -o table
"""

helps['acr taskrun logs'] = """
type: command
short-summary: Show logs for a particular run.
examples:
- name: Show logs for a particular run.
text: >
az acr task logs -r MyRegistry --run-id runId
"""

helps['acr token'] = """
type: group
short-summary: Manage tokens for an Azure Container Registry.
Expand Down
4 changes: 3 additions & 1 deletion src/azure-cli/azure/cli/command_modules/acr/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,12 @@ 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) as g:
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')
Expand Down
8 changes: 6 additions & 2 deletions src/azure-cli/azure/cli/command_modules/acr/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
build_timers_info,
remove_timer_trigger,
get_task_id_from_task_name,
prepare_source_location
prepare_source_location,
user_confirmation
)
from ._stream_utils import stream_logs
from ._constants import (
Expand Down Expand Up @@ -283,9 +284,12 @@ def acr_task_delete(cmd,
client,
task_name,
registry_name,
resource_group_name=None):
resource_group_name=None,
yes=False):
_, resource_group_name = validate_managed_registry(
cmd, registry_name, resource_group_name, TASK_NOT_SUPPORTED)

user_confirmation("Are you sure you want to delete the task '{}' ".format(task_name), yes)
return client.delete(resource_group_name, registry_name, task_name)


Expand Down
17 changes: 16 additions & 1 deletion src/azure-cli/azure/cli/command_modules/acr/taskrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# 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
)

Expand Down Expand Up @@ -35,7 +37,20 @@ def acr_taskrun_delete(cmd,
client,
taskrun_name,
registry_name,
resource_group_name=None):
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)

Large diffs are not rendered by default.

Loading

0 comments on commit ec34523

Please sign in to comment.