1use std::fmt::Display;
11
12pub mod controller;
13pub mod k8s;
14pub mod metrics;
15pub mod tls;
16
17#[derive(Debug, thiserror::Error)]
18pub enum Error {
19 Anyhow(#[from] anyhow::Error),
20 Kube(#[from] kube::Error),
21 Reqwest(#[from] reqwest::Error),
22}
23
24impl Display for Error {
25 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26 match self {
27 Self::Anyhow(e) => write!(f, "{e}"),
28 Self::Kube(e) => write!(f, "{e}"),
29 Self::Reqwest(e) => write!(f, "{e}"),
30 }
31 }
32}
33
34pub fn matching_image_from_environmentd_image_ref(
35 environmentd_image_ref: &str,
36 image_name: &str,
37 image_tag: Option<&str>,
38) -> String {
39 let namespace = environmentd_image_ref
40 .rsplit_once('/')
41 .unwrap_or(("materialize", ""))
42 .0;
43 let tag = image_tag.unwrap_or_else(|| {
44 environmentd_image_ref
45 .rsplit_once(':')
46 .unwrap_or(("", "unstable"))
47 .1
48 });
49 format!("{namespace}/{image_name}:{tag}")
50}