pub struct ConnectionSpec {
pub secret_ref: Option<SecretReference>,
pub secret_key: Option<String>,
pub params: Option<ConnectionParams>,
}Expand description
Database connection configuration.
Supports two mutually exclusive modes:
Mode 1 — Single URL (backward-compatible):
connection:
secretRef: { name: my-secret }
secretKey: DATABASE_URL # optional, defaults to DATABASE_URLMode 2 — Structured params (for Zalando/CNPG/PGO secrets):
connection:
params:
host: my-cluster-postgres
port: 5432
dbname: mydb
usernameSecret: { name: zalando-creds, key: username }
passwordSecret: { name: zalando-creds, key: password }Params mode can also use provider-backed authentication instead of a static password, for example GKE Workload Identity to Cloud SQL IAM.
Fields§
§secret_ref: Option<SecretReference>Reference to a Kubernetes Secret containing a connection URL.
Mutually exclusive with params.
secret_key: Option<String>Key within the Secret to read. Defaults to DATABASE_URL.
Only used with secretRef.
params: Option<ConnectionParams>Structured connection parameters. Each field is either a plain string
or a reference to a Secret key. Mutually exclusive with secretRef.
Implementations§
Source§impl ConnectionSpec
impl ConnectionSpec
Sourcepub fn effective_secret_key(&self) -> &str
pub fn effective_secret_key(&self) -> &str
Effective secret key for URL mode. Defaults to DATABASE_URL.
Sourcepub fn collect_secret_names(&self, names: &mut BTreeSet<String>)
pub fn collect_secret_names(&self, names: &mut BTreeSet<String>)
Collect all Secret names referenced by this connection spec.
Sourcepub fn identity_key(&self) -> String
pub fn identity_key(&self) -> String
Deterministic identity key for this connection spec.
- URL mode:
{secret_ref.name}/{secret_key} - Params mode: canonical representation of the params
Uses \0 as field separator since null bytes cannot appear in K8s names
or secret values, avoiding ambiguity from colons in literal values.
Deterministic identity key for per-database locking and conflict detection.
Identifies the target database (host + port + dbname) but NOT the credentials. Two policies targeting the same database with different users should still be considered as targeting the same database for locking and overlap checks.
Trait Implementations§
Source§impl Clone for ConnectionSpec
impl Clone for ConnectionSpec
Source§fn clone(&self) -> ConnectionSpec
fn clone(&self) -> ConnectionSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConnectionSpec
impl Debug for ConnectionSpec
Source§impl<'de> Deserialize<'de> for ConnectionSpec
impl<'de> Deserialize<'de> for ConnectionSpec
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for ConnectionSpec
impl JsonSchema for ConnectionSpec
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreAuto Trait Implementations§
impl Freeze for ConnectionSpec
impl RefUnwindSafe for ConnectionSpec
impl Send for ConnectionSpec
impl Sync for ConnectionSpec
impl Unpin for ConnectionSpec
impl UnsafeUnpin for ConnectionSpec
impl UnwindSafe for ConnectionSpec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request