本文整理匯總了Golang中github.com/openshift/origin/pkg/route/api.Route類的典型用法代碼示例。如果您正苦於以下問題:Golang Route類的具體用法?Golang Route怎麽用?Golang Route使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Route類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: convert_v1_Route_To_api_Route
func convert_v1_Route_To_api_Route(in *Route, out *newer.Route, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
out.Path = in.Spec.Path
out.Host = in.Spec.Host
if in.Spec.To.Kind == "Service" || len(in.Spec.To.Kind) == 0 {
out.ServiceName = in.Spec.To.Name
}
return s.Convert(&in.Spec.TLS, &out.TLS, 0)
}
示例2: allocateHost
// allocateHost allocates a host name ONLY if the host name on the route is empty and an allocator
// is configured. It must first allocate the shard and may return an error if shard allocation
// fails.
func (s routeStrategy) allocateHost(route *api.Route) error {
if len(route.Spec.Host) == 0 && s.RouteAllocator != nil {
// TODO: this does not belong here, and should be removed
shard, err := s.RouteAllocator.AllocateRouterShard(route)
if err != nil {
return errors.NewInternalError(fmt.Errorf("allocation error: %v for route: %#v", err, route))
}
route.Spec.Host = s.RouteAllocator.GenerateHostname(route, shard)
if route.Annotations == nil {
route.Annotations = map[string]string{}
}
route.Annotations[HostGeneratedAnnotationKey] = "true"
}
return nil
}