Skip to content

Commit

Permalink
enable unstructured cache
Browse files Browse the repository at this point in the history
  • Loading branch information
Cezar Guimaraes committed Sep 18, 2024
1 parent 3ce4645 commit bcf0fe5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
9 changes: 7 additions & 2 deletions controllers/conditionalttl_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ import (
"context"
"errors"
"fmt"
"github.com/vtex/cleaner-controller/custom_cel"
"strings"
"time"

"github.com/vtex/cleaner-controller/custom_cel"

cloudevents "github.com/cloudevents/sdk-go/v2"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/storage/driver"
Expand Down Expand Up @@ -199,7 +201,10 @@ func (r *ConditionalTTLReconciler) Reconcile(ctx context.Context, req ctrl.Reque
// given a labelSelector.
func (r *ConditionalTTLReconciler) resolveTarget(ctx context.Context, namespace string, t *cleanerv1alpha1.Target) (runtime.Unstructured, error) {
log := log.FromContext(ctx)
gvk := schema.FromAPIVersionAndKind(t.Reference.APIVersion, t.Reference.Kind)
gvk := schema.FromAPIVersionAndKind(
t.Reference.APIVersion,
strings.ToUpper(t.Reference.Kind[0:1])+t.Reference.Kind[1:],
)
if t.Reference.Name != nil {
u := &unstructured.Unstructured{}
u.SetGroupVersionKind(gvk)
Expand Down
11 changes: 9 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package main
import (
"flag"
"os"

"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"

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

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
Metrics: server.Options{BindAddress: metricsAddr},
Scheme: scheme,
Metrics: server.Options{BindAddress: metricsAddr},
Client: client.Options{
Cache: &client.CacheOptions{
Unstructured: true,
},
},
WebhookServer: webhook.NewServer(webhook.Options{Port: 9443}),
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
Expand Down

0 comments on commit bcf0fe5

Please sign in to comment.