コード例 #1
0
ファイル: conversion.go プロジェクト: cjnygard/origin
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
0
ファイル: strategy.go プロジェクト: juanluisvaladas/origin
// 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
}