Skip to content

Commit 8b1b821

Browse files
committed
add optional authentication class reference
1 parent bdfb936 commit 8b1b821

3 files changed

Lines changed: 59 additions & 3 deletions

File tree

crates/stackable-operator/crds/OpenLineageConnection.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ spec:
2424
OpenLineage connection definition as a resource.
2525
Learn more about [OpenLineage](https://openlineage.io/).
2626
properties:
27+
authenticationClassRef:
28+
description: |-
29+
Name of an [`AuthenticationClass`](https://docs.stackable.tech/home/nightly/concepts/authentication) used
30+
to authenticate against the OpenLineage backend. The `AuthenticationClass` is cluster-scoped
31+
and referenced by name; it is resolved at runtime via
32+
[`OpenLineageConnectionSpec::resolve_authentication_class`]. If not specified, no
33+
authentication is used.
34+
nullable: true
35+
type: string
2736
host:
2837
description: 'Host of the OpenLineage backend without any protocol or port. For example: `marquez`.'
2938
type: string

crates/stackable-operator/src/crd/openlineage/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ pub mod versioned {
4646
/// When TLS server verification is configured, the transport uses `https` instead of `http`.
4747
#[serde(flatten)]
4848
pub tls: TlsClientDetails,
49+
50+
/// Name of an [`AuthenticationClass`](DOCS_BASE_URL_PLACEHOLDER/concepts/authentication) used
51+
/// to authenticate against the OpenLineage backend. The `AuthenticationClass` is cluster-scoped
52+
/// and referenced by name; it is resolved at runtime via
53+
/// [`OpenLineageConnectionSpec::resolve_authentication_class`]. If not specified, no
54+
/// authentication is used.
55+
#[serde(default, skip_serializing_if = "Option::is_none")]
56+
pub authentication_class_ref: Option<String>,
4957
}
5058

5159
/// An OpenLineage connection, either inlined or referenced by the name of an
@@ -98,6 +106,9 @@ impl stackable_versioned::test_utils::RoundtripTestData for v1alpha1::OpenLineag
98106
server:
99107
caCert:
100108
secretClass: openlineage-cert
109+
- host: marquez
110+
port: 5000
111+
authenticationClassRef: openlineage-auth
101112
"})
102113
.expect("Failed to parse OpenLineageConnectionSpec YAML")
103114
}
@@ -118,6 +129,7 @@ mod tests {
118129
host: "marquez".to_string(),
119130
port: 5000,
120131
tls: TlsClientDetails { tls: None },
132+
authentication_class_ref: None,
121133
};
122134

123135
assert_eq!(connection.transport_url(), "http://marquez:5000");
@@ -135,6 +147,7 @@ mod tests {
135147
}),
136148
}),
137149
},
150+
authentication_class_ref: None,
138151
};
139152

140153
assert_eq!(connection.transport_url(), "https://marquez:5000");
@@ -150,6 +163,7 @@ mod tests {
150163
verification: TlsVerification::None {},
151164
}),
152165
},
166+
authentication_class_ref: None,
153167
};
154168

155169
assert_eq!(connection.transport_url(), "http://marquez:5000");

crates/stackable-operator/src/crd/openlineage/v1alpha1_impl.rs

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@ use snafu::{ResultExt as _, Snafu};
22

33
use crate::{
44
client::Client,
5-
crd::openlineage::{
6-
ResolvedOpenLineageConnection,
7-
v1alpha1::{InlineConnectionOrReference, OpenLineageConnection, OpenLineageConnectionSpec},
5+
crd::{
6+
authentication::core::v1alpha1::AuthenticationClass,
7+
openlineage::{
8+
ResolvedOpenLineageConnection,
9+
v1alpha1::{
10+
InlineConnectionOrReference, OpenLineageConnection, OpenLineageConnectionSpec,
11+
},
12+
},
813
},
914
};
1015

@@ -16,6 +21,13 @@ pub enum OpenLineageError {
1621
source: Box<crate::client::Error>,
1722
open_lineage_connection: String,
1823
},
24+
25+
#[snafu(display("failed to retrieve AuthenticationClass '{authentication_class}'"))]
26+
RetrieveAuthenticationClass {
27+
#[snafu(source(from(crate::client::Error, Box::new)))]
28+
source: Box<crate::client::Error>,
29+
authentication_class: String,
30+
},
1931
}
2032

2133
impl OpenLineageConnectionSpec {
@@ -36,6 +48,27 @@ impl OpenLineageConnectionSpec {
3648
port = self.port
3749
)
3850
}
51+
52+
/// Resolves the [`AuthenticationClass`] referenced by this connection, if any.
53+
///
54+
/// Returns `Ok(None)` when no `authenticationClassRef` is configured. The `AuthenticationClass`
55+
/// is cluster-scoped, so no namespace is required.
56+
pub async fn resolve_authentication_class(
57+
&self,
58+
client: &Client,
59+
) -> Result<Option<AuthenticationClass>, OpenLineageError> {
60+
let Some(authentication_class_ref) = &self.authentication_class_ref else {
61+
return Ok(None);
62+
};
63+
64+
let resolved = AuthenticationClass::resolve(client, authentication_class_ref)
65+
.await
66+
.context(RetrieveAuthenticationClassSnafu {
67+
authentication_class: authentication_class_ref.clone(),
68+
})?;
69+
70+
Ok(Some(resolved))
71+
}
3972
}
4073

4174
impl InlineConnectionOrReference {

0 commit comments

Comments
 (0)