Skip to content

Commit bcf0fe5

Browse files
author
Cezar Guimaraes
committed
enable unstructured cache
1 parent 3ce4645 commit bcf0fe5

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

controllers/conditionalttl_controller.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ import (
2020
"context"
2121
"errors"
2222
"fmt"
23-
"github.com/vtex/cleaner-controller/custom_cel"
23+
"strings"
2424
"time"
2525

26+
"github.com/vtex/cleaner-controller/custom_cel"
27+
2628
cloudevents "github.com/cloudevents/sdk-go/v2"
2729
"helm.sh/helm/v3/pkg/action"
2830
"helm.sh/helm/v3/pkg/storage/driver"
@@ -199,7 +201,10 @@ func (r *ConditionalTTLReconciler) Reconcile(ctx context.Context, req ctrl.Reque
199201
// given a labelSelector.
200202
func (r *ConditionalTTLReconciler) resolveTarget(ctx context.Context, namespace string, t *cleanerv1alpha1.Target) (runtime.Unstructured, error) {
201203
log := log.FromContext(ctx)
202-
gvk := schema.FromAPIVersionAndKind(t.Reference.APIVersion, t.Reference.Kind)
204+
gvk := schema.FromAPIVersionAndKind(
205+
t.Reference.APIVersion,
206+
strings.ToUpper(t.Reference.Kind[0:1])+t.Reference.Kind[1:],
207+
)
203208
if t.Reference.Name != nil {
204209
u := &unstructured.Unstructured{}
205210
u.SetGroupVersionKind(gvk)

main.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ package main
1919
import (
2020
"flag"
2121
"os"
22+
23+
"sigs.k8s.io/controller-runtime/pkg/client"
2224
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
2325
"sigs.k8s.io/controller-runtime/pkg/webhook"
2426

@@ -69,8 +71,13 @@ func main() {
6971
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
7072

7173
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
72-
Scheme: scheme,
73-
Metrics: server.Options{BindAddress: metricsAddr},
74+
Scheme: scheme,
75+
Metrics: server.Options{BindAddress: metricsAddr},
76+
Client: client.Options{
77+
Cache: &client.CacheOptions{
78+
Unstructured: true,
79+
},
80+
},
7481
WebhookServer: webhook.NewServer(webhook.Options{Port: 9443}),
7582
HealthProbeBindAddress: probeAddr,
7683
LeaderElection: enableLeaderElection,

0 commit comments

Comments
 (0)