MCPcopy
hub / github.com/cloudfoundry/cli / Execute

Method Execute

cf/commands/route/unmap_route.go:93–131  ·  view source on GitHub ↗
(c flags.FlagContext)

Source from the content-addressed store, hash-verified

91}
92
93func (cmd *UnmapRoute) Execute(c flags.FlagContext) error {
94 hostName := c.String("n")
95 path := c.String("path")
96 port := c.Int("port")
97 domain := cmd.domainReq.GetDomain()
98 app := cmd.appReq.GetApplication()
99
100 route, err := cmd.routeRepo.Find(hostName, domain, path, port)
101 if err != nil {
102 return err
103 }
104
105 cmd.ui.Say(T("Removing route {{.URL}} from app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...",
106 map[string]interface{}{
107 "URL": terminal.EntityNameColor(route.URL()),
108 "AppName": terminal.EntityNameColor(app.Name),
109 "OrgName": terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
110 "SpaceName": terminal.EntityNameColor(cmd.config.SpaceFields().Name),
111 "Username": terminal.EntityNameColor(cmd.config.Username())}))
112
113 var routeFound bool
114 for _, routeApp := range route.Apps {
115 if routeApp.GUID == app.GUID {
116 routeFound = true
117 err = cmd.routeRepo.Unbind(route.GUID, app.GUID)
118 if err != nil {
119 return err
120 }
121 break
122 }
123 }
124
125 cmd.ui.Ok()
126
127 if !routeFound {
128 cmd.ui.Warn(T("\nRoute to be unmapped is not currently mapped to the application."))
129 }
130 return nil
131}

Callers

nothing calls this directly

Calls 14

EntityNameColorFunction · 0.92
StringMethod · 0.65
IntMethod · 0.65
GetDomainMethod · 0.65
GetApplicationMethod · 0.65
FindMethod · 0.65
SayMethod · 0.65
OrganizationFieldsMethod · 0.65
SpaceFieldsMethod · 0.65
UsernameMethod · 0.65
UnbindMethod · 0.65
OkMethod · 0.65

Tested by

no test coverage detected