func (h *Handler) serviceFunctionChainToProto(serviceFunctionChain *v1.ServiceFunctionChain) *model.ServiceFunctionChain {
	chain := &model.ServiceFunctionChain{
		Name:           serviceFunctionChain.Name,
		Unidirectional: serviceFunctionChain.Spec.Unidirectional,
		Network:        serviceFunctionChain.Spec.Network,
	}
	for _, c := range serviceFunctionChain.Spec.Chain {
		chain.Chain = append(chain.Chain,
			h.serviceFunctionToProto(c))
	}
	return chain
}
serviceFunctionChainToProto converts service function chain data from the Contiv's own CRD representation
to the corresponding protobuf-modelled data format.
package servicefunctionchain
import (
	"errors"
	"github.com/contiv/vpp/plugins/crd/handler/kvdbreflector"
	"github.com/contiv/vpp/plugins/crd/handler/servicefunctionchain/model"
	"github.com/contiv/vpp/plugins/crd/pkg/apis/contivppio/v1"
	crdClientSet "github.com/contiv/vpp/plugins/crd/pkg/client/clientset/versioned"
	apiextv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
)
type Handler struct {
	CrdClient *crdClientSet.Clientset
}
func (h *Handler) CrdName() string {
	return "ServiceFunctionChain"
}
func (h *Handler) CrdKeyPrefix() (prefix string, underKsrPrefix bool) {
	return model.Keyword + "/", true
}
func (h *Handler) IsCrdKeySuffix(keySuffix string) bool {
	return true
}
func (h *Handler) CrdObjectToKVData(obj interface{}) (data []kvdbreflector.KVData, err error) {
	svc, ok := obj.(*v1.ServiceFunctionChain)
	if !ok {
		return nil, errors.New("failed to cast into ServiceFunctionChain struct")
	}
	data = []kvdbreflector.KVData{
		{
			ProtoMsg:  h.serviceFunctionChainToProto(svc),
			KeySuffix: svc.GetName(),
		},
	}
	return
}
func (h *Handler) IsExclusiveKVDB() bool {
	return true
}
func (h *Handler) PublishCrdStatus(obj interface{}, opRetval error) error {
	svc, ok := obj.(*v1.ServiceFunctionChain)
	if !ok {
		return errors.New("failed to cast into ServiceFunctionChain struct")
	}
	svc = svc.DeepCopy()
	if opRetval == nil {
		svc.Status.Status = v1.StatusSuccess
	} else {
		svc.Status.Status = v1.StatusFailure
		svc.Status.Message = opRetval.Error()
	}
	_, err := h.CrdClient.ContivppV1().ServiceFunctionChains(svc.Namespace).Update(svc)
	return err
}