Skip to content

Commit c48595e

Browse files
[AKS][TA] remove source_resource_id of rolebinding update command (#5202)
1 parent ee05e4a commit c48595e

File tree

5 files changed

+23
-13
lines changed

5 files changed

+23
-13
lines changed

src/aks-preview/HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ To release a new version, please select a new version number (usually plus 1 to
1111

1212
Pending
1313
+++++++
14+
* [BREAKING CHANGE] Since the service no longer supports updating source resource id for role binding, so remove --source-resource-id of `aks trustedaccess rolebinding update` command
1415

1516
0.5.93
1617
++++++

src/aks-preview/azext_aks_preview/_help.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,9 +1850,6 @@
18501850
- name: --roles
18511851
type: string
18521852
short-summary: Specify the space-separated roles.
1853-
- name: --source-resource-id -s
1854-
type: string
1855-
short-summary: Specify the source resource id of the binding.
18561853
"""
18571854

18581855
helps['aks trustedaccess rolebinding delete'] = """

src/aks-preview/azext_aks_preview/_params.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -702,12 +702,12 @@ def load_arguments(self, _):
702702
c.argument('role_binding_name', options_list=[
703703
'--name', '-n'], required=True, help='The role binding name.')
704704

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

712712

713713
def _get_default_install_location(exe_name):

src/aks-preview/azext_aks_preview/commands.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,6 @@ def load_command_table(self, _):
199199
with self.command_group('aks trustedaccess rolebinding', trustedaccess_role_binding_sdk, client_factory=cf_trustedaccess_role_binding) as g:
200200
g.custom_command('list', 'aks_trustedaccess_role_binding_list')
201201
g.custom_show_command('show', 'aks_trustedaccess_role_binding_get')
202-
g.custom_command('create', 'aks_trustedaccess_role_binding_create_or_update')
203-
g.custom_command('update', 'aks_trustedaccess_role_binding_create_or_update')
202+
g.custom_command('create', 'aks_trustedaccess_role_binding_create')
203+
g.custom_command('update', 'aks_trustedaccess_role_binding_update')
204204
g.custom_command('delete', 'aks_trustedaccess_role_binding_delete', confirmation=True)

src/aks-preview/azext_aks_preview/custom.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,8 +2218,8 @@ def aks_trustedaccess_role_binding_get(cmd, client, resource_group_name, cluster
22182218
return client.get(resource_group_name, cluster_name, role_binding_name)
22192219

22202220

2221-
def aks_trustedaccess_role_binding_create_or_update(cmd, client, resource_group_name, cluster_name, role_binding_name,
2222-
source_resource_id, roles):
2221+
def aks_trustedaccess_role_binding_create(cmd, client, resource_group_name, cluster_name, role_binding_name,
2222+
source_resource_id, roles):
22232223
TrustedAccessRoleBinding = cmd.get_models(
22242224
"TrustedAccessRoleBinding",
22252225
resource_type=CUSTOM_MGMT_AKS_PREVIEW,
@@ -2229,5 +2229,17 @@ def aks_trustedaccess_role_binding_create_or_update(cmd, client, resource_group_
22292229
return client.create_or_update(resource_group_name, cluster_name, role_binding_name, roleBinding)
22302230

22312231

2232+
def aks_trustedaccess_role_binding_update(cmd, client, resource_group_name, cluster_name, role_binding_name, roles):
2233+
TrustedAccessRoleBinding = cmd.get_models(
2234+
"TrustedAccessRoleBinding",
2235+
resource_type=CUSTOM_MGMT_AKS_PREVIEW,
2236+
operation_group="trusted_access_role_bindings",
2237+
)
2238+
existedBinding = client.get(resource_group_name, cluster_name, role_binding_name)
2239+
2240+
roleBinding = TrustedAccessRoleBinding(source_resource_id=existedBinding.source_resource_id, roles=roles)
2241+
return client.create_or_update(resource_group_name, cluster_name, role_binding_name, roleBinding)
2242+
2243+
22322244
def aks_trustedaccess_role_binding_delete(cmd, client, resource_group_name, cluster_name, role_binding_name):
22332245
return client.delete(resource_group_name, cluster_name, role_binding_name)

0 commit comments

Comments
 (0)