Skip to main content

gestalt/
secrets.rs

1use tonic::codegen::async_trait;
2
3use crate::api::RuntimeMetadata;
4use crate::error::Result;
5
6#[async_trait]
7/// Lifecycle and lookup contract for secrets providers.
8pub trait SecretsProvider: Send + Sync + 'static {
9    /// Configures the provider before it starts serving requests.
10    async fn configure(
11        &self,
12        _name: &str,
13        _config: serde_json::Map<String, serde_json::Value>,
14    ) -> Result<()> {
15        Ok(())
16    }
17
18    /// Returns runtime metadata that should augment the static manifest.
19    fn metadata(&self) -> Option<RuntimeMetadata> {
20        None
21    }
22
23    /// Returns non-fatal warnings the host should surface to users.
24    fn warnings(&self) -> Vec<String> {
25        Vec::new()
26    }
27
28    /// Performs an optional health check.
29    async fn health_check(&self) -> Result<()> {
30        Ok(())
31    }
32
33    /// Starts provider-owned background work after configuration.
34    async fn start(&self) -> Result<()> {
35        Ok(())
36    }
37
38    /// Shuts the provider down before the runtime exits.
39    async fn close(&self) -> Result<()> {
40        Ok(())
41    }
42
43    /// Looks up one named secret.
44    async fn get_secret(&self, name: &str) -> Result<String>;
45}