Skip to content
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] Fix the incorrect output of az acr task identity show -n Name -r Registry -o table #12120

Merged
merged 1 commit into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acr/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def task_output_format(result):
return _output_format(result, _task_format_group)


def task_identity_format(result):
return _output_format(result, _task_identity_format_group)


def taskrun_output_format(result):
return _output_format(result, _taskrun_format_group)

Expand Down Expand Up @@ -188,6 +192,18 @@ def _task_format_group(item):
])


def _task_identity_format_group(item):
identities = _get_array_value(item, 'userAssignedIdentities')
identities_by_line = str('\n'.join(identities)) if identities else ' '

return OrderedDict([
('PRINCIPAL ID', _get_value(item, 'principalId')),
('TENANT ID', _get_value(item, 'tenantId')),
('TYPE', _get_value(item, 'type')),
('USER ASSIGNED IDENTITIES', identities_by_line)
])


def _taskrun_format_group(item):
return OrderedDict([
('NAME', _get_value(item, 'name')),
Expand Down
3 changes: 2 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 @@ -17,6 +17,7 @@
replication_output_format,
build_output_format,
task_output_format,
task_identity_format,
taskrun_output_format,
run_output_format,
helm_list_output_format,
Expand Down Expand Up @@ -223,7 +224,7 @@ def load_command_table(self, _): # pylint: disable=too-many-statements
g.command('update', 'acr_task_update')
g.command('identity assign', 'acr_task_identity_assign')
g.command('identity remove', 'acr_task_identity_remove')
g.command('identity show', 'acr_task_identity_show')
g.command('identity show', 'acr_task_identity_show', table_transformer=task_identity_format)
g.command('credential add', 'acr_task_credential_add')
g.command('credential update', 'acr_task_credential_update')
g.command('credential remove', 'acr_task_credential_remove')
Expand Down