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

{AKS} Add trusted access roles command #4838

Merged
merged 9 commits into from
May 24, 2022
5 changes: 5 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ To release a new version, please select a new version number (usually plus 1 to
Pending
+++++++

0.5.72
++++++

* Add command `aks trustedaccess role list`.

0.5.71
++++++

Expand Down
2 changes: 2 additions & 0 deletions src/aks-preview/azext_aks_preview/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
def get_container_service_client(cli_ctx, **_):
return get_mgmt_service_client(cli_ctx, CUSTOM_MGMT_AKS_PREVIEW)

def cf_trustedaccess(cli_ctx, *_):
return get_container_service_client(cli_ctx).trusted_access_roles

def cf_container_services(cli_ctx, *_):
return get_container_service_client(cli_ctx).container_services
Expand Down
5 changes: 5 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -1704,3 +1704,8 @@
type: command
short-summary: Delete a nodepool snapshot.
"""

helps['aks trustedaccess role list'] = """
type: command
short-summary: List trusted access roles.
"""
3 changes: 3 additions & 0 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,9 @@ def load_arguments(self, _):
c.argument('yes', options_list=[
'--yes', '-y'], help='Do not prompt for confirmation.', action='store_true')

with self.argument_context('aks trustedaccess role') as c:
c.argument('list', required=True, action='store_true', options_list=['--list', '-l'],
help='List the trusted access roles of the subscription')

def _get_default_install_location(exe_name):
system = platform.system()
Expand Down
14 changes: 13 additions & 1 deletion src/aks-preview/azext_aks_preview/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from ._client_factory import cf_agent_pools
from ._client_factory import cf_nodepool_snapshots
from ._client_factory import cf_mc_snapshots
from ._client_factory import cf_trustedaccess
from ._format import aks_show_table_format
from ._format import aks_addon_list_available_table_format, aks_addon_list_table_format, aks_addon_show_table_format
from ._format import aks_agentpool_show_table_format
Expand Down Expand Up @@ -54,7 +55,14 @@ def load_command_table(self, _):
mc_snapshot_sdk = CliCommandType(
operations_tmpl='azext_aks_preview.vendored_sdks.azure_mgmt_preview_aks.'
'operations._managed_clusters_snapshots_operations#ManagedClusterSnapshotsOperations.{}',
client_factory=cf_mc_snapshots)
client_factory=cf_mc_snapshots
)

trustedaccess_sdk = CliCommandType(
operations_tmpl='azext_aks_preview.vendored_sdks.azure_mgmt_preview_aks.'
'operations._trusted_access_roles_operations#TrustedAccessRolesOperations.{}',
client_factory=cf_trustedaccess
)

# AKS managed cluster commands
with self.command_group('aks', managed_clusters_sdk, client_factory=cf_managed_clusters) as g:
Expand Down Expand Up @@ -162,3 +170,7 @@ def load_command_table(self, _):
supports_no_wait=True)
g.custom_command('delete', 'aks_snapshot_delete',
supports_no_wait=True)

# AKS trusted access roles commands
with self.command_group('aks trustedaccess role', trustedaccess_sdk, client_factory=cf_trustedaccess) as g:
g.custom_command('list', 'aks_trustedaccess_roles_list')
3 changes: 3 additions & 0 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3175,3 +3175,6 @@ def aks_nodepool_snapshot_list(cmd, client, resource_group_name=None): # pylint
return client.list()

return client.list_by_resource_group(resource_group_name)

def aks_trustedaccess_roles_list(cmd, client, location): # pylint: disable=unused-argument
return client.list(location)