diff --git a/controllers/conditionalttl_controller.go b/controllers/conditionalttl_controller.go index cbe13ae..7e9de62 100644 --- a/controllers/conditionalttl_controller.go +++ b/controllers/conditionalttl_controller.go @@ -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" @@ -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) diff --git a/main.go b/main.go index 4ae918d..987eae0 100644 --- a/main.go +++ b/main.go @@ -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" @@ -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,