kaniop_operator/kanidm/controller/
context.rs1use crate::controller::context::BackoffContext;
2use crate::metrics::ControllerMetrics;
3use crate::{controller::context::Context as KaniopContext, kanidm::crd::Kanidm};
4
5use std::sync::Arc;
6use std::time::Duration;
7
8use k8s_openapi::api::apps::v1::StatefulSet;
9use k8s_openapi::api::core::v1::{Secret, Service};
10use k8s_openapi::api::networking::v1::Ingress;
11use kube::runtime::reflector::{ObjectRef, Store};
12
13#[derive(Clone)]
14pub struct Context {
15 pub kaniop_ctx: KaniopContext<Kanidm>,
16 pub stores: Arc<Stores>,
18}
19
20impl Context {
21 pub fn new(kaniop_ctx: KaniopContext<Kanidm>, stores: Stores) -> Self {
22 Context {
23 kaniop_ctx,
24 stores: Arc::new(stores),
25 }
26 }
27}
28
29impl BackoffContext<Kanidm> for Context {
30 fn metrics(&self) -> &Arc<ControllerMetrics> {
31 self.kaniop_ctx.metrics()
32 }
33 async fn get_backoff(&self, obj_ref: ObjectRef<Kanidm>) -> Duration {
34 self.kaniop_ctx.get_backoff(obj_ref).await
35 }
36
37 async fn reset_backoff(&self, obj_ref: ObjectRef<Kanidm>) {
38 self.kaniop_ctx.reset_backoff(obj_ref).await
39 }
40}
41
42pub struct Stores {
43 pub stateful_set_store: Store<StatefulSet>,
44 pub service_store: Store<Service>,
45 pub ingress_store: Store<Ingress>,
46 pub secret_store: Store<Secret>,
47}