Exemplo n.º 1
0
func (appRunner *appRunner) buildRoutes(params CreateAppParams, primaryPort uint16) route_helpers.Routes {
	var routes route_helpers.Routes

	var appRoutes route_helpers.AppRoutes
	if params.NoRoutes {
		appRoutes = route_helpers.AppRoutes{}
	} else if len(params.RouteOverrides) > 0 {
		routeMap := make(map[uint16][]string)
		for _, override := range params.RouteOverrides {
			routeMap[override.Port] = append(routeMap[override.Port], fmt.Sprintf("%s.%s", override.HostnamePrefix, appRunner.systemDomain))
		}
		for port, hostnames := range routeMap {
			appRoutes = append(appRoutes, route_helpers.AppRoute{
				Hostnames: hostnames,
				Port:      port,
			})
		}
	} else {
		appRoutes = appRunner.buildDefaultRoutingInfo(params.Name, params.ExposedPorts, primaryPort)
	}

	var tcpRoutes route_helpers.TcpRoutes
	if !params.NoRoutes && len(params.TcpRoutes) > 0 {
		for _, tcpRoute := range params.TcpRoutes {
			tcpRoutes = append(tcpRoutes, route_helpers.TcpRoute{
				ExternalPort: tcpRoute.ExternalPort,
				Port:         tcpRoute.Port,
			})
		}
		routes.TcpRoutes = tcpRoutes
	}

	routes.AppRoutes = appRoutes
	return routes
}
Exemplo n.º 2
0
func (appRunner *appRunner) buildRoutes(noRoutes bool, routeOverrides RouteOverrides, tcpRoutes TcpRoutes) route_helpers.Routes {
	var routes route_helpers.Routes

	var appRoutes route_helpers.AppRoutes
	if noRoutes {
		appRoutes = route_helpers.AppRoutes{}
	} else if len(routeOverrides) > 0 {
		routeMap := make(map[uint16][]string)
		for _, override := range routeOverrides {
			routeMap[override.Port] = append(routeMap[override.Port], fmt.Sprintf("%s.%s", override.HostnamePrefix, appRunner.systemDomain))
		}
		for port, hostnames := range routeMap {
			appRoutes = append(appRoutes, route_helpers.AppRoute{
				Hostnames: hostnames,
				Port:      port,
			})
		}
	}

	var appTcpRoutes route_helpers.TcpRoutes
	if !noRoutes && len(tcpRoutes) > 0 {
		for _, tcpRoute := range tcpRoutes {
			appTcpRoutes = append(appTcpRoutes, route_helpers.TcpRoute{
				ExternalPort: tcpRoute.ExternalPort,
				Port:         tcpRoute.Port,
			})
		}
		routes.TcpRoutes = appTcpRoutes
	}

	routes.AppRoutes = appRoutes
	return routes
}