Files
open-cluster-management/pkg/work/spoke/apply/read_only_apply.go
Jian Qiu 5528aff6d3 🌱 Add contextual logging for work agent (#1242)
* Add contextual logging for work agent

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

* Resolve comments

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

---------

Signed-off-by: Jian Qiu <jqiu@redhat.com>
2025-11-07 05:28:13 +00:00

33 lines
876 B
Go

package apply
import (
"context"
"github.com/openshift/library-go/pkg/operator/events"
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"
)
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
}