func (_ HostEndpoint) APIV1ToBackendV1(a unversioned.Resource) (*model.KVPair, error) {
	ah, ok := a.(*apiv1.HostEndpoint)
	if !ok {
		return nil, fmt.Errorf("value is not a valid v1 HostEndpoint")
	}
	var ipv4Addrs []cnet.IP
	var ipv6Addrs []cnet.IP
	for _, ip := range ah.Spec.ExpectedIPs {
		if ip.Version() == 4 {
			ipv4Addrs = append(ipv4Addrs, ip)
		} else {
			ipv6Addrs = append(ipv6Addrs, ip)
		}
	}
	var ports []model.EndpointPort
	for _, port := range ah.Spec.Ports {
		ports = append(ports, model.EndpointPort{
			Name:     port.Name,
			Protocol: port.Protocol,
			Port:     port.Port,
		})
	}
	d := model.KVPair{
		Key: model.HostEndpointKey{
			Hostname:   ah.Metadata.Node,
			EndpointID: ah.Metadata.Name,
		},
		Value: &model.HostEndpoint{
			Labels:            ah.Metadata.Labels,
			Name:              ah.Spec.InterfaceName,
			ProfileIDs:        ah.Spec.Profiles,
			ExpectedIPv4Addrs: ipv4Addrs,
			ExpectedIPv6Addrs: ipv6Addrs,
			Ports:             ports,
		},
	}
	log.WithFields(log.Fields{
		"v1HostEndpoint": a,
		"KVPair":         d,
	}).Debug("Converted HostEndpoint to KVPair")
	return &d, nil
}
APIV1ToBackendV1 converts an APIv1 HostEndpoint structure to a KVPair containing a
backend HostEndpoint and HostEndpointKey.
This is part of the converter interface.
package converters
import (
	"fmt"
	log "github.com/sirupsen/logrus"
	apiv3 "github.com/projectcalico/api/pkg/apis/projectcalico/v3"
	"github.com/projectcalico/api/pkg/lib/numorstring"
	apiv1 "github.com/projectcalico/libcalico-go/lib/apis/v1"
	"github.com/projectcalico/libcalico-go/lib/apis/v1/unversioned"
	"github.com/projectcalico/libcalico-go/lib/backend/model"
	cnet "github.com/projectcalico/libcalico-go/lib/net"
)
type HostEndpoint struct{}