Skip to content

Commit 922527e

Browse files
committed
refactor: rename RoleApi::get_ownerships to list_ownerships
1 parent 1e24288 commit 922527e

File tree

9 files changed

+18
-17
lines changed

9 files changed

+18
-17
lines changed

src/query/management/src/role/role_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub trait RoleApi: Sync + Send {
3232

3333
async fn get_raw_meta_roles(&self) -> Result<ListKVReply>;
3434

35-
async fn get_ownerships(&self) -> Result<Vec<SeqV<OwnershipInfo>>>;
35+
async fn list_ownerships(&self) -> Result<Vec<SeqV<OwnershipInfo>>>;
3636

3737
/// General role update.
3838
///

src/query/management/src/role/role_mgr.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl RoleApi for RoleMgr {
211211

212212
#[async_backtrace::framed]
213213
#[fastrace::trace]
214-
async fn get_ownerships(&self) -> Result<Vec<SeqV<OwnershipInfo>>, ErrorCode> {
214+
async fn list_ownerships(&self) -> Result<Vec<SeqV<OwnershipInfo>>, ErrorCode> {
215215
let object_owner_prefix = self.ownership_object_prefix();
216216
let values = self
217217
.kv_api
@@ -229,7 +229,7 @@ impl RoleApi for RoleMgr {
229229
// After rollback the old version, deserialize will return Err Ownership can not be none.
230230
// But get ownerships should try to ensure success because in this version.
231231
Err(err) => error!(
232-
"deserialize key {} Got err {} while (get_ownerships)",
232+
"deserialize key {} Got err {} while (list_ownerships)",
233233
&key, err
234234
),
235235
}
@@ -270,11 +270,11 @@ impl RoleApi for RoleMgr {
270270

271271
/// Only drop role will call transfer.
272272
///
273-
/// If a role is dropped, but the owner object is exists,
273+
/// If a role is dropped, but the owner object is existing,
274274
///
275275
/// The owner role need to update to account_admin.
276276
///
277-
/// get_ownerships use prefix_list_kv that will generate once meta call
277+
/// list_ownerships use prefix_list_kv that will generate once meta call
278278
///
279279
/// According to Txn reduce meta call. If role own n objects, will generate once meta call.
280280
#[async_backtrace::framed]
@@ -288,7 +288,7 @@ impl RoleApi for RoleMgr {
288288
trials.next().unwrap().map_err(AppError::from)?.await;
289289
let mut if_then = vec![];
290290
let mut condition = vec![];
291-
let seq_owns = self.get_ownerships().await.map_err(|e| {
291+
let seq_owns = self.list_ownerships().await.map_err(|e| {
292292
e.add_message_back("(while in transfer_ownership_to_admin get ownerships).")
293293
})?;
294294
let mut need_transfer = false;

src/query/service/src/interpreters/access/privilege_access.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ impl AccessChecker for PrivilegeAccess {
765765
let user_api = UserApiProvider::instance();
766766
let ownerships = user_api
767767
.role_api(&tenant)
768-
.get_ownerships()
768+
.list_ownerships()
769769
.await?;
770770
let roles = self.ctx.get_all_effective_roles().await?;
771771
let roles_name: Vec<String> = roles.iter().map(|role| role.name.to_string()).collect();
@@ -783,7 +783,7 @@ impl AccessChecker for PrivilegeAccess {
783783
let user_api = UserApiProvider::instance();
784784
let ownerships = user_api
785785
.role_api(&tenant)
786-
.get_ownerships()
786+
.list_ownerships()
787787
.await?;
788788
let roles = self.ctx.get_all_effective_roles().await?;
789789
let roles_name: Vec<String> = roles.iter().map(|role| role.name.to_string()).collect();
@@ -938,7 +938,7 @@ impl AccessChecker for PrivilegeAccess {
938938
let user_api = UserApiProvider::instance();
939939
let ownerships = user_api
940940
.role_api(&tenant)
941-
.get_ownerships()
941+
.list_ownerships()
942942
.await?;
943943
let roles = self.ctx.get_all_effective_roles().await?;
944944
let roles_name: Vec<String> = roles.iter().map(|role| role.name.to_string()).collect();

src/query/service/src/sessions/session_privilege_mgr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ impl SessionPrivilegeManager for SessionPrivilegeManagerImpl<'_> {
397397
let user_api = UserApiProvider::instance();
398398
let ownerships = user_api
399399
.role_api(&self.session_ctx.get_current_tenant())
400-
.get_ownerships()
400+
.list_ownerships()
401401
.await?;
402402
let mut ownership_objects = vec![];
403403
for ownership in ownerships {

src/query/service/src/table_functions/show_grants/show_grants_table.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ async fn show_account_grants(
495495
// 2. not expand roles
496496
// So no need to get ownerships.
497497
if !roles.is_empty() {
498-
let ownerships = user_api.role_api(&tenant).get_ownerships().await?;
498+
let ownerships = user_api.role_api(&tenant).list_ownerships().await?;
499499
for ownership in ownerships {
500500
if roles.contains(&ownership.data.role) {
501501
match ownership.data.object {
@@ -807,7 +807,7 @@ async fn show_object_grant(
807807
}
808808
}
809809

810-
let ownerships = user_api.role_api(&tenant).get_ownerships().await?;
810+
let ownerships = user_api.role_api(&tenant).list_ownerships().await?;
811811
for ownership in ownerships {
812812
if ownership.data.object == owner_object {
813813
privileges.push("OWNERSHIP".to_string());

src/query/storages/system/src/streams_table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl<const T: bool> AsyncSystemTable for StreamsTable<T> {
157157
.collect::<Vec<_>>();
158158

159159
let ownership = if T {
160-
user_api.get_ownerships(&tenant).await.unwrap_or_default()
160+
user_api.list_ownerships(&tenant).await.unwrap_or_default()
161161
} else {
162162
HashMap::new()
163163
};

src/query/storages/system/src/tables_table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ where TablesTable<WITH_HISTORY, WITHOUT_VIEW>: HistoryAware
543543
dbs.clear();
544544

545545
let ownership = if get_ownership {
546-
user_api.get_ownerships(&tenant).await.unwrap_or_default()
546+
user_api.list_ownerships(&tenant).await.unwrap_or_default()
547547
} else {
548548
HashMap::new()
549549
};

src/query/users/src/role_mgr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ impl UserApiProvider {
8484
}
8585

8686
#[async_backtrace::framed]
87-
pub async fn get_ownerships(
87+
pub async fn list_ownerships(
8888
&self,
8989
tenant: &Tenant,
9090
) -> Result<HashMap<OwnershipObject, String>> {
9191
let seq_owns = self
9292
.role_api(tenant)
93-
.get_ownerships()
93+
.list_ownerships()
9494
.await
9595
.map_err(|e| e.add_message_back("(while get ownerships)."))?;
9696

@@ -172,7 +172,7 @@ impl UserApiProvider {
172172
if let Some(owner) = ownership {
173173
// if object has ownership, but the owner role is not exists, set owner role to ACCOUNT_ADMIN,
174174
// only account_admin can access this object.
175-
// Note: get_ownerships no need to do this check.
175+
// Note: list_ownerships no need to do this check.
176176
// Because this can cause system.table queries to slow down
177177
// The intention is that the account admin can grant ownership.
178178
// So system.tables will display dropped role. It's by design.

src/query/users/src/user_api.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ impl UserApiProvider {
6565
) -> Result<()> {
6666
GlobalInstance::set(Self::try_create(conf, builtin, tenant).await?);
6767
let user_mgr = UserApiProvider::instance();
68+
6869
if let Some(q) = quota {
6970
let i = user_mgr.tenant_quota_api(tenant);
7071
let res = i.get_quota(MatchSeq::GE(0)).await?;

0 commit comments

Comments
 (0)