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: gateway_conversion.go
    path of file: ./repos/kuma/pkg/plugins/runtime/k8s/controllers/gatewayapi
    
    the code of the file until where you have to start completion: package gatewayapi

import (
	"context"
	"fmt"
	"strings"

	kube_core "k8s.io/api/core/v1"
	kube_apierrs "k8s.io/apimachinery/pkg/api/errors"
	kube_apimeta "k8s.io/apimachinery/pkg/api/meta"
	kube_meta "k8s.io/apimachinery/pkg/apis/meta/v1"
	kube_types "k8s.io/apimachinery/pkg/types"
	kube_client "sigs.k8s.io/controller-runtime/pkg/client"
	gatewayapi_v1 "sigs.k8s.io/gateway-api/apis/v1"
	gatewayapi "sigs.k8s.io/gateway-api/apis/v1beta1"

	mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1"
	system_proto "github.com/kumahq/kuma/api/system/v1alpha1"
	mesh_k8s "github.com/kumahq/kuma/pkg/plugins/resources/k8s/native/api/v1alpha1"
	"github.com/kumahq/kuma/pkg/plugins/runtime/k8s/controllers/gatewayapi/common"
	referencegrants "github.com/kumahq/kuma/pkg/plugins/runtime/k8s/controllers/gatewayapi/referencegrants"
	"github.com/kumahq/kuma/pkg/util/pointer"
)

type ListenerConditions map[gatewayapi.SectionName][]kube_meta.Condition

func validProtocol(crossMesh bool, protocol gatewayapi.ProtocolType) bool {
	switch protocol {
	case gatewayapi_v1.HTTPProtocolType, gatewayapi_v1.HTTPSProtocolType:
		return !crossMesh || protocol == gatewayapi_v1.HTTPProtocolType
	default:
	}

	return false
}

func ValidateListeners(crossMesh bool, listeners []gatewayapi.Listener) ([]gatewayapi.Listener, ListenerConditions) {
	var validListeners []gatewayapi.Listener
	listenerConditions := ListenerConditions{}

	appendDetachedCondition := func(
		listener gatewayapi.SectionName,
		reason gatewayapi.ListenerConditionReason,
		message string,
	) {
		listenerConditions[listener] = append(
			listenerConditions[listener],
			kube_meta.Condition{
				Type
    
func handleConditions(conditions []kube_meta.Condition, unresolvableCertRef *certRefCondition) []kube_meta.Condition {
	// We've already cleared this listener of conflicts and being detached
	conditions = append(
		conditions,
		kube_meta.Condition{
			Type:   string(gatewayapi_v1.ListenerConditionAccepted),
			Status: kube_meta.ConditionTrue,
			Reason: string(gatewayapi_v1.ListenerReasonAccepted),
		},
		kube_meta.Condition{
			Type:   string(gatewayapi_v1.ListenerConditionConflicted),
			Status: kube_meta.ConditionFalse,
			Reason: string(gatewayapi_v1.ListenerReasonNoConflicts),
		},
	)

	var resolvedRefConditions []kube_meta.Condition

	if unresolvableCertRef != nil && !kube_apimeta.IsStatusConditionFalse(conditions, string(gatewayapi_v1.ListenerConditionResolvedRefs)) {
		kube_apimeta.SetStatusCondition(&conditions,
			kube_meta.Condition{
				Type:    string(gatewayapi_v1.ListenerConditionResolvedRefs),
				Status:  kube_meta.ConditionFalse,
				Reason:  unresolvableCertRef.reason,
				Message: unresolvableCertRef.message,
			},
		)
	}

	if !kube_apimeta.IsStatusConditionFalse(conditions, string(gatewayapi_v1.ListenerConditionResolvedRefs)) {
		kube_apimeta.SetStatusCondition(&conditions,
			kube_meta.Condition{
				Type:   string(gatewayapi_v1.ListenerConditionResolvedRefs),
				Status: kube_meta.ConditionTrue,
				Reason: string(gatewayapi_v1.ListenerReasonResolvedRefs),
			},
		)
		kube_apimeta.SetStatusCondition(&conditions,
			kube_meta.Condition{
				Type:   string(gatewayapi_v1.ListenerConditionProgrammed),
				Status: kube_meta.ConditionTrue,
				Reason: string(gatewayapi_v1.ListenerReasonProgrammed),
			},
		)
	} else {
		kube_apimeta.SetStatusCondition(&conditions,
			kube_meta.Condition{
				Type:    string(gatewayapi_v1.ListenerConditionProgrammed),
				Status:  kube_meta.ConditionFalse,
				Reason:  string(gatewayapi_v1.ListenerReasonInvalid),
				Message: "unable to resolve refs",
			},
		)
	}

	return append(conditions, resolvedRefConditions...)
}