func (cmd *CreateRoute) CreateRoute(hostName string, domain cf.DomainFields, space cf.SpaceFields) (route cf.Route, apiResponse net.ApiResponse) { cmd.ui.Say("Creating route %s for org %s / space %s as %s...", terminal.EntityNameColor(domain.UrlForHost(hostName)), terminal.EntityNameColor(cmd.config.OrganizationFields.Name), terminal.EntityNameColor(space.Name), terminal.EntityNameColor(cmd.config.Username()), ) route, apiResponse = cmd.routeRepo.CreateInSpace(hostName, domain.Guid, space.Guid) if apiResponse.IsNotSuccessful() { var findApiResponse net.ApiResponse route, findApiResponse = cmd.routeRepo.FindByHostAndDomain(hostName, domain.Name) if findApiResponse.IsNotSuccessful() || route.Space.Guid != space.Guid || route.Domain.Guid != domain.Guid { return } apiResponse = net.NewSuccessfulApiResponse() cmd.ui.Ok() cmd.ui.Warn("Route %s already exists", route.URL()) return } cmd.ui.Ok() return }
func (cmd *Push) route(hostName string, domain cf.DomainFields) (route cf.Route) { route, apiResponse := cmd.routeRepo.FindByHostAndDomain(hostName, domain.Name) if apiResponse.IsNotSuccessful() { cmd.ui.Say("Creating route %s...", terminal.EntityNameColor(domain.UrlForHost(hostName))) route, apiResponse = cmd.routeRepo.Create(hostName, domain.Guid) if apiResponse.IsNotSuccessful() { cmd.ui.Failed(apiResponse.Message) return } cmd.ui.Ok() cmd.ui.Say("") } else { cmd.ui.Say("Using route %s", terminal.EntityNameColor(route.URL())) } return }