Skip to content

Commit

Permalink
chore: rename admission to ephemeral in reports aggregation controller (
Browse files Browse the repository at this point in the history
kyverno#9690)

Signed-off-by: Charles-Edouard Brétéché <[email protected]>
  • Loading branch information
eddycharly authored Feb 7, 2024
1 parent c815e9b commit 6f440ab
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions pkg/controllers/report/aggregate/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func NewController(
c.queue.AddAfter(res.Namespace+"/"+string(uid), enqueueDelay)
}
})
enqueueFromAdmr := func(obj metav1.Object) {
enqueueFromEphemeral := func(obj metav1.Object) {
switch reportutils.GetSource(obj) {
case "background-scan":
c.queue.AddAfter(controllerutils.MetaObjectToName(obj), enqueueDelay)
Expand All @@ -144,17 +144,17 @@ func NewController(
}
if _, err := controllerutils.AddEventHandlersT(
ephrInformer.Informer(),
func(obj metav1.Object) { enqueueFromAdmr(obj) },
func(_, obj metav1.Object) { enqueueFromAdmr(obj) },
func(obj metav1.Object) { enqueueFromAdmr(obj) },
func(obj metav1.Object) { enqueueFromEphemeral(obj) },
func(_, obj metav1.Object) { enqueueFromEphemeral(obj) },
func(obj metav1.Object) { enqueueFromEphemeral(obj) },
); err != nil {
logger.Error(err, "failed to register event handlers")
}
if _, err := controllerutils.AddEventHandlersT(
cephrInformer.Informer(),
func(obj metav1.Object) { enqueueFromAdmr(obj) },
func(_, obj metav1.Object) { enqueueFromAdmr(obj) },
func(obj metav1.Object) { enqueueFromAdmr(obj) },
func(obj metav1.Object) { enqueueFromEphemeral(obj) },
func(_, obj metav1.Object) { enqueueFromEphemeral(obj) },
func(obj metav1.Object) { enqueueFromEphemeral(obj) },
); err != nil {
logger.Error(err, "failed to register event handlers")
}
Expand Down Expand Up @@ -244,7 +244,7 @@ func (c *controller) getBackgroundScanReport(ctx context.Context, namespace, nam
}
}

func (c *controller) getAdmissionReports(ctx context.Context, namespace, name string) ([]kyvernov1alpha2.ReportInterface, error) {
func (c *controller) getEphemeralReports(ctx context.Context, namespace, name string) ([]kyvernov1alpha2.ReportInterface, error) {
selector, err := reportutils.SelectorResourceUidEquals(types.UID(name))
if err != nil {
return nil, err
Expand Down Expand Up @@ -305,22 +305,22 @@ func (c *controller) getPolicyReport(ctx context.Context, namespace, name string
}

func (c *controller) getReports(ctx context.Context, namespace, name string) ([]kyvernov1alpha2.ReportInterface, kyvernov1alpha2.ReportInterface, error) {
admissionReports, err := c.getAdmissionReports(ctx, namespace, name)
ephemeralReports, err := c.getEphemeralReports(ctx, namespace, name)
if err != nil {
return nil, nil, err
}
backgroundReport, err := c.getBackgroundScanReport(ctx, namespace, name)
if err != nil {
return nil, nil, err
}
return admissionReports, backgroundReport, nil
return ephemeralReports, backgroundReport, nil
}

func (c *controller) reconcile(ctx context.Context, logger logr.Logger, _, namespace, name string) error {
uid := types.UID(name)
resource, gvk, exists := c.metadataCache.GetResourceHash(uid)
if exists {
admissionReports, backgroundReport, err := c.getReports(ctx, namespace, name)
ephemeralReports, backgroundReport, err := c.getReports(ctx, namespace, name)
if err != nil {
return err
}
Expand Down Expand Up @@ -354,7 +354,7 @@ func (c *controller) reconcile(ctx context.Context, logger logr.Logger, _, names
var reports []kyvernov1alpha2.ReportInterface
reports = append(reports, policyReport)
reports = append(reports, backgroundReport)
reports = append(reports, admissionReports...)
reports = append(reports, ephemeralReports...)
mergeReports(policyMap, vapMap, merged, uid, reports...)
var results []policyreportv1alpha2.PolicyReportResult
for _, result := range merged {
Expand All @@ -378,8 +378,8 @@ func (c *controller) reconcile(ctx context.Context, logger logr.Logger, _, names
}
}
}
for _, admissionReport := range admissionReports {
if err := deleteReport(ctx, admissionReport, c.client); err != nil {
for _, ephemeralReport := range ephemeralReports {
if err := deleteReport(ctx, ephemeralReport, c.client); err != nil {
return err
}
}
Expand All @@ -396,7 +396,7 @@ func (c *controller) reconcile(ctx context.Context, logger logr.Logger, _, names
if policyReport == nil {
return nil
}
admissionReports, backgroundReport, err := c.getReports(ctx, namespace, name)
ephemeralReports, backgroundReport, err := c.getReports(ctx, namespace, name)
if err != nil {
return err
}
Expand All @@ -413,7 +413,7 @@ func (c *controller) reconcile(ctx context.Context, logger logr.Logger, _, names
var reports []kyvernov1alpha2.ReportInterface
reports = append(reports, policyReport)
reports = append(reports, backgroundReport)
reports = append(reports, admissionReports...)
reports = append(reports, ephemeralReports...)
mergeReports(policyMap, vapMap, merged, uid, reports...)
var results []policyreportv1alpha2.PolicyReportResult
for _, result := range merged {
Expand Down

0 comments on commit 6f440ab

Please sign in to comment.