risingwave_frontend/catalog/system_catalog/rw_catalog/
rw_secrets.rs1use risingwave_common::types::Fields;
16use risingwave_frontend_macro::system_catalog;
17
18use crate::catalog::system_catalog::{SysCatalogReaderImpl, get_acl_items};
19use crate::error::Result;
20
21#[derive(Fields)]
22struct RwSecret {
23 #[primary_key]
24 id: i32,
25 schema_id: i32,
26 name: String,
27 owner: i32,
28 acl: Vec<String>,
29}
30
31#[system_catalog(table, "rw_catalog.rw_secrets")]
32fn read_rw_secret_info(reader: &SysCatalogReaderImpl) -> Result<Vec<RwSecret>> {
33 let catalog_reader = reader.catalog_reader.read_guard();
34 let schemas = catalog_reader.iter_schemas(&reader.auth_context.database)?;
35 let user_reader = reader.user_info_reader.read_guard();
36 let users = user_reader.get_all_users();
37 let current_user = user_reader
38 .get_user_by_name(&reader.auth_context.user_name)
39 .expect("user not found");
40 let username_map = user_reader.get_user_name_map();
41
42 Ok(schemas
43 .flat_map(|schema| {
44 schema
45 .iter_secret_with_acl(current_user)
46 .map(|secret| RwSecret {
47 id: secret.id.as_i32_id(),
48 schema_id: secret.schema_id.as_i32_id(),
49 name: secret.name.clone(),
50 owner: secret.owner as i32,
51 acl: get_acl_items(secret.id, false, &users, username_map),
52 })
53 })
54 .collect())
55}