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

Method Execute

cf/commands/route/delete_route.go:89–128  ·  view source on GitHub ↗
(c flags.FlagContext)

Source from the content-addressed store, hash-verified

87}
88
89func (cmd *DeleteRoute) Execute(c flags.FlagContext) error {
90 host := c.String("n")
91 path := c.String("path")
92 domainName := c.Args()[0]
93 port := c.Int("port")
94
95 url := (&models.RoutePresenter{
96 Host: host,
97 Domain: domainName,
98 Path: path,
99 Port: port,
100 }).URL()
101
102 if !c.Bool("f") {
103 if !cmd.ui.ConfirmDelete("route", url) {
104 return nil
105 }
106 }
107
108 cmd.ui.Say(T("Deleting route {{.URL}}...", map[string]interface{}{"URL": terminal.EntityNameColor(url)}))
109
110 domain := cmd.domainReq.GetDomain()
111 route, err := cmd.routeRepo.Find(host, domain, path, port)
112 if err != nil {
113 if _, ok := err.(*errors.ModelNotFoundError); ok {
114 cmd.ui.Warn(T("Unable to delete, route '{{.URL}}' does not exist.",
115 map[string]interface{}{"URL": url}))
116 return nil
117 }
118 return err
119 }
120
121 err = cmd.routeRepo.Delete(route.GUID)
122 if err != nil {
123 return err
124 }
125
126 cmd.ui.Ok()
127 return nil
128}

Callers

nothing calls this directly

Calls 13

EntityNameColorFunction · 0.92
StringMethod · 0.65
ArgsMethod · 0.65
IntMethod · 0.65
BoolMethod · 0.65
ConfirmDeleteMethod · 0.65
SayMethod · 0.65
GetDomainMethod · 0.65
FindMethod · 0.65
WarnMethod · 0.65
DeleteMethod · 0.65
OkMethod · 0.65

Tested by

no test coverage detected