MCPcopy Index your code
hub / github.com/cloudfoundry/cli / CreateRoute

Method CreateRoute

cf/commands/route/create_route.go:121–154  ·  view source on GitHub ↗
(hostName string, path string, port int, randomPort bool, domain models.DomainFields, space models.SpaceFields)

Source from the content-addressed store, hash-verified

119}
120
121func (cmd *CreateRoute) CreateRoute(hostName string, path string, port int, randomPort bool, domain models.DomainFields, space models.SpaceFields) (models.Route, error) {
122 cmd.ui.Say(T("Creating route {{.URL}} for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...",
123 map[string]interface{}{
124 "URL": terminal.EntityNameColor(domain.URLForHostAndPath(hostName, path, port)),
125 "OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
126 "SpaceName": terminal.EntityNameColor(space.Name),
127 "Username": terminal.EntityNameColor(cmd.config.Username())}))
128
129 route, err := cmd.routeRepo.CreateInSpace(hostName, path, domain.GUID, space.GUID, port, randomPort)
130 if err != nil {
131 var findErr error
132 route, findErr = cmd.routeRepo.Find(hostName, domain, path, port)
133 if findErr != nil {
134 return models.Route{}, err
135 }
136
137 if route.Space.GUID != space.GUID || route.Domain.GUID != domain.GUID {
138 return models.Route{}, err
139 }
140
141 cmd.ui.Ok()
142 cmd.ui.Warn(T("Route {{.URL}} already exists",
143 map[string]interface{}{"URL": route.URL()}))
144
145 return route, nil
146 }
147
148 cmd.ui.Ok()
149 if randomPort {
150 cmd.ui.Say("Route %s:%d has been created", route.Domain.Name, route.Port)
151 }
152
153 return route, nil
154}

Callers 1

ExecuteMethod · 0.95

Calls 10

EntityNameColorFunction · 0.92
URLForHostAndPathMethod · 0.80
SayMethod · 0.65
OrganizationFieldsMethod · 0.65
UsernameMethod · 0.65
CreateInSpaceMethod · 0.65
FindMethod · 0.65
OkMethod · 0.65
WarnMethod · 0.65
URLMethod · 0.45

Tested by

no test coverage detected