Skip to content

MapObject.Object contains empty GroupVersionKind #284

@liyinan926

Description

@liyinan926

I noticed that MapObject.Object instances passed to a handler.ToRequestsFunc function contains empty GroupVersionKind. The code I have looks like the following:

mapFn := handler.ToRequestsFunc(
	func(a handler.MapObject) []reconcile.Request {
		var requests []reconcile.Request
		apps := listApplications(mgr.GetClient(), a.Meta.GetNamespace())
		for _, app := range apps {
			ref := app.Spec.Selector.ObjectRef
			gvk := a.Object.GetObjectKind().GroupVersionKind()
			if gvk.Empty() {
				log.Printf("Empty GVK for object %s/%s", a.Meta.GetNamespace(), a.Meta.GetName())
				return requests
			}
			if ref != nil && ref.Name == a.Meta.GetName() && ref.Kind == gvk.Kind {
				requests = append(requests, reconcile.Request{
					NamespacedName: types.NamespacedName{
						Namespace: app.Namespace,
						Name:      app.Name,
					},
				})
			}
		}
		return requests
	})

The logs show multiple occurrences of Empty GVK for object ....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions