From 8079023bccffcf463397741944edda101291b521 Mon Sep 17 00:00:00 2001 From: Leandro Mendes Date: Tue, 28 Jan 2025 17:31:40 +0100 Subject: [PATCH] feat: add more objects to cache Signed-off-by: Leandro Mendes --- main.go | 10 ++++++++++ metadata/labels.go | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 633d7303e..dd33ecb99 100644 --- a/main.go +++ b/main.go @@ -107,9 +107,19 @@ func main() { mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ Cache: cache.Options{ ByObject: map[client.Object]cache.ByObject{ + // we want to cache PipelineRuns only created by this operator. &tektonv1.PipelineRun{}: cache.ByObject{ Label: labels.SelectorFromSet(labels.Set{metadata.ServiceNameLabel: metadata.ServiceName}), }, + // also cache other watched objects, but no filter is required. + &appstudiov1alpha1.Release{}: {}, + &appstudiov1alpha1.ReleasePlan{}: {}, + &appstudiov1alpha1.ReleasePlanAdmission{}: {}, + // objects that the operator does not watch, but are used by it. + &appstudiov1alpha1.ReleaseServiceConfig{}: {}, + &applicationapiv1alpha1.Snapshot{}: {}, + &applicationapiv1alpha1.Component{}: {}, + &applicationapiv1alpha1.Application{}: {}, }, }, HealthProbeBindAddress: probeAddr, diff --git a/metadata/labels.go b/metadata/labels.go index 8de238c77..6a41ddf99 100644 --- a/metadata/labels.go +++ b/metadata/labels.go @@ -20,7 +20,7 @@ import "fmt" // Common constants const ( - // rhtapDomain is the prefix of the application label + // RhtapDomain is the prefix of the application label RhtapDomain = "appstudio.openshift.io" // MaxLabelLength is the maximum allowed characters in a label value @@ -51,7 +51,7 @@ var ( AutomatedLabel = fmt.Sprintf("release.%s/automated", RhtapDomain) // ServiceNameLabel is the label used to specify the service associated with an object - ServiceNameLabel = fmt.Sprintf("%s/%s", rhtapDomain, "service") + ServiceNameLabel = fmt.Sprintf("%s/%s", RhtapDomain, "service") // ReleasePlanAdmissionLabel is the ReleasePlan label for the name of the ReleasePlanAdmission to use ReleasePlanAdmissionLabel = fmt.Sprintf("release.%s/releasePlanAdmission", RhtapDomain)