Files
Jian Qiu 33310619d9 🌱 use SDK basecontroller for better logging. (#1269)
* Use basecontroller in sdk-go instead for better logging

Signed-off-by: Jian Qiu <jqiu@redhat.com>

* Rename to fakeSyncContext

Signed-off-by: Jian Qiu <jqiu@redhat.com>

---------

Signed-off-by: Jian Qiu <jqiu@redhat.com>
2025-12-01 03:07:02 +00:00

33 lines
884 B
Go

package apply
import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/klog/v2"
workapiv1 "open-cluster-management.io/api/work/v1"
"open-cluster-management.io/sdk-go/pkg/basecontroller/events"
)
type ReadOnlyApply struct{}
func NewReadOnlyApply() *ReadOnlyApply {
return &ReadOnlyApply{}
}
func (c *ReadOnlyApply) Apply(ctx context.Context,
gvr schema.GroupVersionResource,
required *unstructured.Unstructured,
_ metav1.OwnerReference,
_ *workapiv1.ManifestConfigOption,
_ events.Recorder) (runtime.Object, error) {
logger := klog.FromContext(ctx)
logger.Info("Noop because its read-only",
"gvr", gvr.String(), "resourceNamespace", required.GetNamespace(), "resourceName", required.GetName())
return required, nil
}