-
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathdereference.rs
More file actions
45 lines (38 loc) · 1.45 KB
/
Copy pathdereference.rs
File metadata and controls
45 lines (38 loc) · 1.45 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
//! The dereference step in the ZookeeperCluster controller.
//!
//! Fetches all Kubernetes objects referenced by the [`v1alpha1::ZookeeperCluster`] spec and
//! returns them in [`DereferencedObjects`]. Synchronous validation of the fetched objects
//! (image resolution, product-config validation, security struct assembly) happens in the
//! validate step.
use snafu::{ResultExt, Snafu};
use stackable_operator::client::Client;
use crate::crd::{
authentication::{self, DereferencedAuthenticationClasses},
v1alpha1,
};
#[derive(Snafu, Debug)]
pub enum Error {
#[snafu(display("failed to fetch authentication classes"))]
FetchAuthenticationClasses { source: authentication::Error },
}
type Result<T, E = Error> = std::result::Result<T, E>;
/// Kubernetes objects referenced from the [`v1alpha1::ZookeeperCluster`] spec, already fetched but
/// not yet validated.
pub struct DereferencedObjects {
pub authentication_classes: DereferencedAuthenticationClasses,
}
/// Fetches all Kubernetes objects referenced from the [`v1alpha1::ZookeeperCluster`] spec.
pub async fn dereference(
client: &Client,
zk: &v1alpha1::ZookeeperCluster,
) -> Result<DereferencedObjects> {
let authentication_classes = DereferencedAuthenticationClasses::fetch_references(
client,
&zk.spec.cluster_config.authentication,
)
.await
.context(FetchAuthenticationClassesSnafu)?;
Ok(DereferencedObjects {
authentication_classes,
})
}