mirror of
https://github.com/paralus/paralus.git
synced 2026-08-24 15:47:19 +00:00
update project details for cluster operations in system audit logs
This commit is contained in:
@@ -444,7 +444,7 @@ func RevokeKubeconfigAuditEvent(ctx context.Context, al *zap.Logger, user string
|
||||
}
|
||||
}
|
||||
|
||||
func CreateClusterAuditEvent(ctx context.Context, al *zap.Logger, action string, name string, id uuid.UUID) {
|
||||
func CreateClusterAuditEvent(ctx context.Context, al *zap.Logger, action string, name string, id uuid.UUID, project string) {
|
||||
sd, ok := GetSessionDataFromContext(ctx)
|
||||
if !ok {
|
||||
_log.Warn("unable to create audit event: could not fetch info from context")
|
||||
@@ -457,7 +457,7 @@ func CreateClusterAuditEvent(ctx context.Context, al *zap.Logger, action string,
|
||||
"cluster_name": name,
|
||||
},
|
||||
}
|
||||
if err := audit.CreateV1Event(al, sd, detail, fmt.Sprintf("cluster.%s.success", action), ""); err != nil {
|
||||
if err := audit.CreateV1Event(al, sd, detail, fmt.Sprintf("cluster.%s.success", action), project); err != nil {
|
||||
_log.Warn("unable to create audit event", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,7 +299,7 @@ func (s *clusterService) Create(ctx context.Context, cluster *infrav3.Cluster) (
|
||||
h.OnChange(ev)
|
||||
}
|
||||
|
||||
CreateClusterAuditEvent(ctx, s.al, AuditActionCreate, clusterResp.GetMetadata().GetName(), edb.ID)
|
||||
CreateClusterAuditEvent(ctx, s.al, AuditActionCreate, clusterResp.GetMetadata().GetName(), edb.ID, cluster.Metadata.Project)
|
||||
return clusterResp, nil
|
||||
}
|
||||
|
||||
@@ -598,13 +598,14 @@ func (s *clusterService) Update(ctx context.Context, cluster *infrav3.Cluster) (
|
||||
h.OnChange(ev)
|
||||
}*/
|
||||
|
||||
CreateClusterAuditEvent(ctx, s.al, AuditActionUpdate, cluster.GetMetadata().GetName(), cdb.ID)
|
||||
CreateClusterAuditEvent(ctx, s.al, AuditActionUpdate, cluster.GetMetadata().GetName(), cdb.ID, cluster.Metadata.Project)
|
||||
|
||||
return cluster, nil
|
||||
}
|
||||
|
||||
func (s *clusterService) Delete(ctx context.Context, cluster *infrav3.Cluster) error {
|
||||
|
||||
projectName := cluster.Metadata.Project
|
||||
cluster, err := s.Get(ctx, func(qo *commonv3.QueryOptions) {
|
||||
qo.Name = cluster.Metadata.Name
|
||||
qo.Project = cluster.Metadata.Project
|
||||
@@ -646,7 +647,7 @@ func (s *clusterService) Delete(ctx context.Context, cluster *infrav3.Cluster) e
|
||||
|
||||
id, err := uuid.Parse(clusterId)
|
||||
if err == nil {
|
||||
CreateClusterAuditEvent(ctx, s.al, AuditActionDelete, cluster.GetMetadata().GetName(), id)
|
||||
CreateClusterAuditEvent(ctx, s.al, AuditActionDelete, cluster.GetMetadata().GetName(), id, projectName)
|
||||
}
|
||||
return nil
|
||||
|
||||
|
||||
Reference in New Issue
Block a user