in appconfigmgrv2/controllers/istio_virtual_services.go [63:99]
func istioVirtualServices(t *appconfig.AppEnvConfigTemplateV2) ([]*unstructured.Unstructured, error) {
list := make([]*unstructured.Unstructured, 0, len(t.Spec.Services))
gvk := istioVirtualServiceGVK()
for i := range t.Spec.Services {
var (
meta = map[string]interface{}{
"name": istioVirtualServiceName(t, i),
"namespace": t.Namespace,
}
spec = &istionet.VirtualService{
Hosts: []string{serviceName(t, i)},
Http: []*istionet.HTTPRoute{{
Match: []*istionet.HTTPMatchRequest{{
Uri: &istionet.StringMatch{
MatchType: &istionet.StringMatch_Prefix{
Prefix: "/",
},
},
}},
Route: []*istionet.HTTPRouteDestination{{
Destination: &istionet.Destination{
Host: serviceName(t, i),
},
}},
}},
}
)
unst, err := unstructuredFromProto(gvk, meta, spec)
if err != nil {
return nil, fmt.Errorf("unstructured from proto: %v", err)
}
list = append(list, unst)
}
return list, nil
}