func MakeIstioStore(store ConfigStore) IstioConfigStore {
	return &istioConfigStore{store}
}
MakeIstioStore creates a wrapper around a store
package model
import (
	"errors"
	"fmt"
	"sort"
	"github.com/golang/protobuf/proto"
	multierror "github.com/hashicorp/go-multierror"
	proxyconfig "istio.io/api/proxy/v1/config"
	"istio.io/pilot/model/test"
)
type ConfigMeta struct {
	Type string `json:"type,omitempty"`
	Name string `json:"name,omitempty"`
	Namespace string `json:"namespace,omitempty"`
	Domain string `json:"domain,omitempty"`
	Labels map[string]string `json:"labels,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`
	ResourceVersion string `json:"resourceVersion,omitempty"`
}
type Config struct {
	ConfigMeta
	Spec proto.Message
}
type ConfigStore interface {
	ConfigDescriptor() ConfigDescriptor
	Get(typ, name, namespace string) (config *Config, exists bool)
	List(typ, namespace string) ([]Config, error)
	Create(config Config) (revision string, err error)
	Update(config Config) (newRevision string, err error)
	Delete(typ, name, namespace string) error
}
func Key(typ, name, namespace string) string {
	return fmt.Sprintf("%s/%s/%s", typ, namespace, name)
}
func (meta *ConfigMeta) Key() string {
	return Key(meta.Type, meta.Name, meta.Namespace)
}
type ConfigStoreCache interface {
	ConfigStore
	RegisterEventHandler(typ string, handler func(Config, Event))
	Run(stop <-chan struct{})
	HasSynced() bool
}
type ConfigDescriptor []ProtoSchema
type ProtoSchema struct {
	Type string
	Plural string
	MessageName string
	Validate func(config proto.Message) error
}
func (descriptor ConfigDescriptor) Types() []string {
	types := make([]string, 0, len(descriptor))
	for _, t := range descriptor {
		types = append(types, t.Type)
	}
	return types
}
func (descriptor ConfigDescriptor) GetByMessageName(name string) (ProtoSchema, bool) {
	for _, schema := range descriptor {
		if schema.MessageName == name {
			return schema, true
		}
	}
	return ProtoSchema{}, false
}
func (descriptor ConfigDescriptor) GetByType(name string) (ProtoSchema, bool) {
	for _, schema := range descriptor {
		if schema.Type == name {
			return schema, true
		}
	}
	return ProtoSchema{}, false
}
type IstioConfigStore interface {
	ConfigStore
	EgressRules() map[string]*proxyconfig.EgressRule
	RouteRules(source []*ServiceInstance, destination string) []Config
	RouteRulesByDestination(destination []*ServiceInstance) []Config
	Policy(source []*ServiceInstance, destination string, labels Labels) *Config
}
const (
	IstioAPIGroup = "config.istio.io"
	IstioAPIVersion = "v1alpha2"
	HeaderURI = "uri"
	HeaderAuthority = "authority"
	NamespaceAll = ""
)
var (
	MockConfig = ProtoSchema{
		Type:        "mock-config",
		Plural:      "mock-configs",
		MessageName: "test.MockConfig",
		Validate: func(config proto.Message) error {
			if config.(*test.MockConfig).Key == "" {
				return errors.New("empty key")
			}
			return nil
		},
	}
	RouteRule = ProtoSchema{
		Type:        "route-rule",
		Plural:      "route-rules",
		MessageName: "istio.proxy.v1.config.RouteRule",
		Validate:    ValidateRouteRule,
	}
	IngressRule = ProtoSchema{
		Type:        "ingress-rule",
		Plural:      "ingress-rules",
		MessageName: "istio.proxy.v1.config.IngressRule",
		Validate:    ValidateIngressRule,
	}
	EgressRule = ProtoSchema{
		Type:        "egress-rule",
		Plural:      "egress-rules",
		MessageName: "istio.proxy.v1.config.EgressRule",
		Validate:    ValidateEgressRule,
	}
	DestinationPolicy = ProtoSchema{
		Type:        "destination-policy",
		Plural:      "destination-policies",
		MessageName: "istio.proxy.v1.config.DestinationPolicy",
		Validate:    ValidateDestinationPolicy,
	}
	IstioConfigTypes = ConfigDescriptor{
		RouteRule,
		IngressRule,
		EgressRule,
		DestinationPolicy,
	}
)
func ResolveHostname(meta ConfigMeta, svc *proxyconfig.IstioService) string {
	out := svc.Name
	if svc.Service != "" {
		out = svc.Service
	} else {
		if svc.Namespace != "" {
			out = out + "." + svc.Namespace
		} else if meta.Namespace != "" {
			out = out + "." + meta.Namespace
		}
		if svc.Domain != "" {
			out = out + "." + svc.Domain
		} else if meta.Domain != "" {
			out = out + ".svc." + meta.Domain
		}
	}
	return out
}
type istioConfigStore struct {
	ConfigStore
}