Skip to content

Commit

Permalink
[AKS][TA] remove source_resource_id of rolebinding update command
Browse files Browse the repository at this point in the history
  • Loading branch information
Yitong Feng committed Aug 5, 2022
1 parent 6a6badc commit 866a41c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
3 changes: 0 additions & 3 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -1850,9 +1850,6 @@
- name: --roles
type: string
short-summary: Specify the space-separated roles.
- name: --source-resource-id -s
type: string
short-summary: Specify the source resource id of the binding.
"""

helps['aks trustedaccess rolebinding delete'] = """
Expand Down
15 changes: 9 additions & 6 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,12 +692,15 @@ def load_arguments(self, _):
c.argument('role_binding_name', options_list=[
'--name', '-n'], required=True, help='The role binding name.')

for scope in ['aks trustedaccess rolebinding create', 'aks trustedaccess rolebinding update']:
with self.argument_context(scope) as c:
c.argument('roles', nargs='*',
help='space-separated roles: Microsoft.Demo/samples/reader Microsoft.Demo/samples/writer ...')
c.argument('source_resource_id', options_list=['--source-resource-id', '-s'],
help='The source resource id of the binding')
with self.argument_context('aks trustedaccess rolebinding create') as c:
c.argument('roles', nargs='*',
help='space-separated roles: Microsoft.Demo/samples/reader Microsoft.Demo/samples/writer ...')
c.argument('source_resource_id', options_list=['--source-resource-id', '-s'],
help='The source resource id of the binding')

with self.argument_context('aks trustedaccess rolebinding update') as c:
c.argument('roles', nargs='*',
help='space-separated roles: Microsoft.Demo/samples/reader Microsoft.Demo/samples/writer ...')


def _get_default_install_location(exe_name):
Expand Down
4 changes: 2 additions & 2 deletions src/aks-preview/azext_aks_preview/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,6 @@ def load_command_table(self, _):
with self.command_group('aks trustedaccess rolebinding', trustedaccess_role_binding_sdk, client_factory=cf_trustedaccess_role_binding) as g:
g.custom_command('list', 'aks_trustedaccess_role_binding_list')
g.custom_show_command('show', 'aks_trustedaccess_role_binding_get')
g.custom_command('create', 'aks_trustedaccess_role_binding_create_or_update')
g.custom_command('update', 'aks_trustedaccess_role_binding_create_or_update')
g.custom_command('create', 'aks_trustedaccess_role_binding_create')
g.custom_command('update', 'aks_trustedaccess_role_binding_update')
g.custom_command('delete', 'aks_trustedaccess_role_binding_delete', confirmation=True)
16 changes: 14 additions & 2 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2218,8 +2218,8 @@ def aks_trustedaccess_role_binding_get(cmd, client, resource_group_name, cluster
return client.get(resource_group_name, cluster_name, role_binding_name)


def aks_trustedaccess_role_binding_create_or_update(cmd, client, resource_group_name, cluster_name, role_binding_name,
source_resource_id, roles):
def aks_trustedaccess_role_binding_create(cmd, client, resource_group_name, cluster_name, role_binding_name,
source_resource_id, roles):
TrustedAccessRoleBinding = cmd.get_models(
"TrustedAccessRoleBinding",
resource_type=CUSTOM_MGMT_AKS_PREVIEW,
Expand All @@ -2229,5 +2229,17 @@ def aks_trustedaccess_role_binding_create_or_update(cmd, client, resource_group_
return client.create_or_update(resource_group_name, cluster_name, role_binding_name, roleBinding)


def aks_trustedaccess_role_binding_update(cmd, client, resource_group_name, cluster_name, role_binding_name, roles):
TrustedAccessRoleBinding = cmd.get_models(
"TrustedAccessRoleBinding",
resource_type=CUSTOM_MGMT_AKS_PREVIEW,
operation_group="trusted_access_role_bindings",
)
existedBinding = client.get(resource_group_name, cluster_name, role_binding_name)

roleBinding = TrustedAccessRoleBinding(source_resource_id=existedBinding.source_resource_id, roles=roles)
return client.create_or_update(resource_group_name, cluster_name, role_binding_name, roleBinding)


def aks_trustedaccess_role_binding_delete(cmd, client, resource_group_name, cluster_name, role_binding_name):
return client.delete(resource_group_name, cluster_name, role_binding_name)

0 comments on commit 866a41c

Please sign in to comment.