You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: find.go
    path of file: ./repos/devspace/pkg/devspace/services/podreplace
    
    the code of the file until where you have to start completion: package podreplace

import (
	"fmt"
	"github.com/loft-sh/devspace/pkg/devspace/config/loader"
	runtimevar "github.com/loft-sh/devspace/pkg/devspace/config/loader/variable/runtime"
	"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
	devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context"
	"github.com/loft-sh/devspace/pkg/devspace/imageselector"
	"github.com/pkg/errors"
	corev1 "k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/api/meta"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/labels"
	"k8s.io/apimachinery/pkg/runtime"
)

func findTargetByKindName(ctx devspacecontext.Context, kind, namespace, name string) (runtime.
    
func findTargetBySelector(ctx devspacecontext.Context, devPod *latest.DevPod, filter func(obj metav1.Object) bool) (runtime.Object, error) {
	namespace := ctx.KubeClient().Namespace()
	if devPod.Namespace != "" {
		namespace = devPod.Namespace
	}

	// deployments
	deployments, err := ctx.KubeClient().KubeClient().AppsV1().Deployments(namespace).List(ctx.Context(), metav1.ListOptions{})
	if err != nil {
		return nil, errors.Wrap(err, "list Deployments")
	}
	for _, d := range deployments.Items {
		if filter != nil && !filter(&d) {
			continue
		}

		matched, err := matchesSelector(ctx, &d.Spec.Template, devPod)
		if err != nil {
			return nil, err
		} else if matched {
			d.Kind = "Deployment"
			return &d, nil
		}
	}

	// replicaSets
	replicaSets, err := ctx.KubeClient().KubeClient().AppsV1().ReplicaSets(namespace).List(ctx.Context(), metav1.ListOptions{})
	if err != nil {
		return nil, errors.Wrap(err, "list ReplicaSets")
	}
	for _, d := range replicaSets.Items {
		if len(d.OwnerReferences) > 0 || (filter != nil && !filter(&d)) {
			continue
		}

		matched, err := matchesSelector(ctx, &d.Spec.Template, devPod)
		if err != nil {
			return nil, err
		} else if matched {
			d.Kind = "ReplicaSet"
			return &d, nil
		}
	}

	// statefulSets
	statefulSets, err := ctx.KubeClient().KubeClient().AppsV1().StatefulSets(namespace).List(ctx.Context(), metav1.ListOptions{})
	if err != nil {
		return nil, errors.Wrap(err, "list StatefulSets")
	}
	for _, d := range statefulSets.Items {
		if filter != nil && !filter(&d) {
			continue
		}

		matched, err := matchesSelector(ctx, &d.Spec.Template, devPod)
		if err != nil {
			return nil, err
		} else if matched {
			d.Kind = "StatefulSet"
			return &d, nil
		}
	}

	return nil, nil
}