fluentci_graphql/schema/objects/
secret_manager.rs

1use std::sync::{Arc, Mutex};
2
3use crate::schema::objects::secret::Secret;
4use async_graphql::{Context, Error, Object, ID};
5use fluentci_common::common;
6use fluentci_core::deps::Graph;
7
8#[derive(Debug, Clone, Default)]
9pub struct SecretManager {
10    pub id: ID,
11}
12
13#[Object]
14impl SecretManager {
15    async fn id(&self) -> &ID {
16        &self.id
17    }
18
19    async fn get_secret(&self, ctx: &Context<'_>, name: String) -> Result<Vec<Secret>, Error> {
20        let graph = ctx.data::<Arc<Mutex<Graph>>>().unwrap();
21        let secret = common::get_secret(graph.clone(), self.id.as_str(), &name)?;
22        Ok(secret.into_iter().map(Into::into).collect())
23    }
24}