risingwave_connector/
enforce_secret.rs1use phf::{Set, phf_set};
16
17use crate::error::ConnectorResult as Result;
18
19#[derive(Debug, thiserror::Error)]
20#[error("{key} is enforced to be a SECRET on RisingWave Cloud, please use `CREATE SECRET` first")]
21pub struct EnforceSecretError {
22 pub key: String,
23}
24
25pub trait EnforceSecret {
26 const ENFORCE_SECRET_PROPERTIES: Set<&'static str> = phf_set! {};
27
28 fn enforce_secret<'a>(prop_iter: impl Iterator<Item = &'a str>) -> Result<()> {
29 for prop in prop_iter {
30 if Self::ENFORCE_SECRET_PROPERTIES.contains(prop) {
31 return Err(EnforceSecretError {
32 key: prop.to_owned(),
33 }
34 .into());
35 }
36 }
37 Ok(())
38 }
39
40 fn enforce_one(prop: &str) -> Result<()> {
41 if Self::ENFORCE_SECRET_PROPERTIES.contains(prop) {
42 return Err(EnforceSecretError {
43 key: prop.to_owned(),
44 }
45 .into());
46 }
47 Ok(())
48 }
49}