Cleaned up events
All checks were successful
Build and deploy / Build container and manifests (push) Successful in 9m7s
All checks were successful
Build and deploy / Build container and manifests (push) Successful in 9m7s
This commit is contained in:
parent
d21b53cf34
commit
9c37b2a2d1
|
@ -34,23 +34,19 @@ pub trait ControllerEvents {
|
|||
where
|
||||
T: Resource<DynamicType = ()> + Sync;
|
||||
|
||||
async fn user_created<T>(&self, obj: &T, username: &str) -> Result<(), Self::Error>
|
||||
async fn user_created<T>(&self, obj: &T) -> Result<(), Self::Error>
|
||||
where
|
||||
T: Resource<DynamicType = ()> + Sync;
|
||||
|
||||
async fn group_created<T>(&self, obj: &T, name: &str) -> Result<(), Self::Error>
|
||||
async fn group_created<T>(&self, obj: &T) -> Result<(), Self::Error>
|
||||
where
|
||||
T: Resource<DynamicType = ()> + Sync;
|
||||
|
||||
async fn user_deleted<T>(&self, obj: &T, username: &str) -> Result<(), Self::Error>
|
||||
async fn user_deleted<T>(&self, obj: &T) -> Result<(), Self::Error>
|
||||
where
|
||||
T: Resource<DynamicType = ()> + Sync;
|
||||
|
||||
async fn group_deleted<T>(&self, obj: &T, name: &str) -> Result<(), Self::Error>
|
||||
where
|
||||
T: Resource<DynamicType = ()> + Sync;
|
||||
|
||||
async fn user_not_found<T>(&self, obj: &T, username: &str) -> Result<(), Self::Error>
|
||||
async fn group_deleted<T>(&self, obj: &T) -> Result<(), Self::Error>
|
||||
where
|
||||
T: Resource<DynamicType = ()> + Sync;
|
||||
|
||||
|
@ -87,16 +83,16 @@ impl ControllerEvents for Recorder {
|
|||
.await
|
||||
}
|
||||
|
||||
async fn user_created<T>(&self, obj: &T, username: &str) -> Result<(), Self::Error>
|
||||
async fn user_created<T>(&self, obj: &T) -> Result<(), Self::Error>
|
||||
where
|
||||
T: Resource<DynamicType = ()> + Sync,
|
||||
{
|
||||
self.publish(
|
||||
&Event {
|
||||
type_: EventType::Normal,
|
||||
reason: "UserCreated".into(),
|
||||
note: Some(format!("Created user '{username}'")),
|
||||
action: "UserCreated".into(),
|
||||
reason: "Created".into(),
|
||||
note: Some("Created user".into()),
|
||||
action: "Created".into(),
|
||||
secondary: None,
|
||||
},
|
||||
&obj.object_ref(&()),
|
||||
|
@ -104,16 +100,16 @@ impl ControllerEvents for Recorder {
|
|||
.await
|
||||
}
|
||||
|
||||
async fn group_created<T>(&self, obj: &T, name: &str) -> Result<(), Self::Error>
|
||||
async fn group_created<T>(&self, obj: &T) -> Result<(), Self::Error>
|
||||
where
|
||||
T: Resource<DynamicType = ()> + Sync,
|
||||
{
|
||||
self.publish(
|
||||
&Event {
|
||||
type_: EventType::Normal,
|
||||
reason: "GroupCreated".into(),
|
||||
note: Some(format!("Created group '{name}'")),
|
||||
action: "GroupCreated".into(),
|
||||
reason: "Created".into(),
|
||||
note: Some("Created group".into()),
|
||||
action: "Created".into(),
|
||||
secondary: None,
|
||||
},
|
||||
&obj.object_ref(&()),
|
||||
|
@ -121,16 +117,16 @@ impl ControllerEvents for Recorder {
|
|||
.await
|
||||
}
|
||||
|
||||
async fn user_deleted<T>(&self, obj: &T, username: &str) -> Result<(), Self::Error>
|
||||
async fn user_deleted<T>(&self, obj: &T) -> Result<(), Self::Error>
|
||||
where
|
||||
T: Resource<DynamicType = ()> + Sync,
|
||||
{
|
||||
self.publish(
|
||||
&Event {
|
||||
type_: EventType::Normal,
|
||||
reason: "UserDeleted".into(),
|
||||
note: Some(format!("Deleted user '{username}'")),
|
||||
action: "UserDeleted".into(),
|
||||
reason: "Deleted".into(),
|
||||
note: Some("Deleted user".into()),
|
||||
action: "Deleted".into(),
|
||||
secondary: None,
|
||||
},
|
||||
&obj.object_ref(&()),
|
||||
|
@ -138,33 +134,16 @@ impl ControllerEvents for Recorder {
|
|||
.await
|
||||
}
|
||||
|
||||
async fn group_deleted<T>(&self, obj: &T, name: &str) -> Result<(), Self::Error>
|
||||
async fn group_deleted<T>(&self, obj: &T) -> Result<(), Self::Error>
|
||||
where
|
||||
T: Resource<DynamicType = ()> + Sync,
|
||||
{
|
||||
self.publish(
|
||||
&Event {
|
||||
type_: EventType::Normal,
|
||||
reason: "GroupDeleted".into(),
|
||||
note: Some(format!("Deleted group '{name}'")),
|
||||
action: "GroupDeleted".into(),
|
||||
secondary: None,
|
||||
},
|
||||
&obj.object_ref(&()),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn user_not_found<T>(&self, obj: &T, username: &str) -> Result<(), Self::Error>
|
||||
where
|
||||
T: Resource<DynamicType = ()> + Sync,
|
||||
{
|
||||
self.publish(
|
||||
&Event {
|
||||
type_: EventType::Warning,
|
||||
reason: "UserNotFound".into(),
|
||||
note: Some(format!("User '{username}' not found")),
|
||||
action: "UserNotFound".into(),
|
||||
reason: "Deleted".into(),
|
||||
note: Some("Deleted group".into()),
|
||||
action: "Deleted".into(),
|
||||
secondary: None,
|
||||
},
|
||||
&obj.object_ref(&()),
|
||||
|
|
|
@ -39,7 +39,7 @@ impl Reconcile for Group {
|
|||
|
||||
lldap_client.create_group(&name).await?;
|
||||
|
||||
ctx.recorder.group_created(self.as_ref(), &name).await?;
|
||||
ctx.recorder.group_created(self.as_ref()).await?;
|
||||
} else {
|
||||
trace!("Group already exists");
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ impl Reconcile for Group {
|
|||
|
||||
lldap_client.delete_group(group.id).await?;
|
||||
|
||||
ctx.recorder.group_deleted(self.as_ref(), &name).await?;
|
||||
ctx.recorder.group_deleted(self.as_ref()).await?;
|
||||
} else {
|
||||
trace!(name, "Group does not exist")
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ impl Reconcile for ServiceUser {
|
|||
debug!(name, username, "Creating new user");
|
||||
|
||||
let user = lldap_client.create_user(&username).await?;
|
||||
ctx.recorder.user_created(self.as_ref(), &username).await?;
|
||||
ctx.recorder.user_created(self.as_ref()).await?;
|
||||
|
||||
Ok(user)
|
||||
}
|
||||
|
@ -208,14 +208,11 @@ impl Reconcile for ServiceUser {
|
|||
Err(lldap::Error::GraphQl(err))
|
||||
if err.message == format!("Entity not found: `No such user: '{username}'`") =>
|
||||
{
|
||||
ctx.recorder
|
||||
.user_not_found(self.as_ref(), &username)
|
||||
.await?;
|
||||
warn!(name, username, "User not found");
|
||||
Ok(())
|
||||
}
|
||||
Ok(_) => {
|
||||
ctx.recorder.user_deleted(self.as_ref(), &username).await?;
|
||||
ctx.recorder.user_deleted(self.as_ref()).await?;
|
||||
Ok(())
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
|
|
|
@ -11,11 +11,7 @@ use serde::{Deserialize, Serialize};
|
|||
use serde_json::json;
|
||||
use tracing::{debug, trace, warn};
|
||||
|
||||
use crate::{
|
||||
context::ControllerEvents,
|
||||
lldap,
|
||||
resources::{Error, user_attribute},
|
||||
};
|
||||
use crate::{context::ControllerEvents, lldap, resources::Error};
|
||||
|
||||
use super::Reconcile;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user