diff --git a/src/aks-preview/HISTORY.rst b/src/aks-preview/HISTORY.rst index 696f43fde91..6db83c33a69 100644 --- a/src/aks-preview/HISTORY.rst +++ b/src/aks-preview/HISTORY.rst @@ -11,6 +11,7 @@ To release a new version, please select a new version number (usually plus 1 to Pending +++++++ +* [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 0.5.92 ++++++ diff --git a/src/aks-preview/azext_aks_preview/_help.py b/src/aks-preview/azext_aks_preview/_help.py index 4255dff9454..889303ad569 100644 --- a/src/aks-preview/azext_aks_preview/_help.py +++ b/src/aks-preview/azext_aks_preview/_help.py @@ -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'] = """ diff --git a/src/aks-preview/azext_aks_preview/_params.py b/src/aks-preview/azext_aks_preview/_params.py index 59433eeabf0..49e4d1521ae 100644 --- a/src/aks-preview/azext_aks_preview/_params.py +++ b/src/aks-preview/azext_aks_preview/_params.py @@ -692,12 +692,12 @@ 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): diff --git a/src/aks-preview/azext_aks_preview/commands.py b/src/aks-preview/azext_aks_preview/commands.py index f3e032c0d11..9766512e77d 100644 --- a/src/aks-preview/azext_aks_preview/commands.py +++ b/src/aks-preview/azext_aks_preview/commands.py @@ -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) diff --git a/src/aks-preview/azext_aks_preview/custom.py b/src/aks-preview/azext_aks_preview/custom.py index bd893840ce1..16e601a906a 100644 --- a/src/aks-preview/azext_aks_preview/custom.py +++ b/src/aks-preview/azext_aks_preview/custom.py @@ -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, @@ -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)