-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathv1alpha1_impl.rs
More file actions
62 lines (56 loc) · 1.78 KB
/
Copy pathv1alpha1_impl.rs
File metadata and controls
62 lines (56 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use snafu::{ResultExt as _, Snafu};
use crate::{
client::Client,
crd::openlineage::{
ResolvedOpenLineageConnection,
v1alpha1::{InlineConnectionOrReference, OpenLineageConnection, OpenLineageConnectionSpec},
},
};
#[derive(Debug, Snafu)]
pub enum OpenLineageError {
#[snafu(display("failed to retrieve OpenLineage connection '{open_lineage_connection}'"))]
RetrieveOpenLineageConnection {
#[snafu(source(from(crate::client::Error, Box::new)))]
source: Box<crate::client::Error>,
open_lineage_connection: String,
},
}
impl OpenLineageConnectionSpec {
/// Build the OpenLineage transport URL from this connection.
///
/// The scheme is `https` when TLS server verification is configured
/// (`tls.verification.server`), otherwise `http`.
pub fn transport_url(&self) -> String {
let scheme = if self.tls.uses_tls_verification() {
"https"
} else {
"http"
};
format!(
"{scheme}://{host}:{port}",
host = self.host,
port = self.port
)
}
}
impl InlineConnectionOrReference {
pub async fn resolve(
self,
client: &Client,
namespace: &str,
) -> Result<ResolvedOpenLineageConnection, OpenLineageError> {
match self {
Self::Inline(inline) => Ok(inline),
Self::Reference(reference) => {
let connection_spec = client
.get::<OpenLineageConnection>(&reference, namespace)
.await
.context(RetrieveOpenLineageConnectionSnafu {
open_lineage_connection: reference,
})?
.spec;
Ok(connection_spec)
}
}
}
}