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

Method Execute

command/v7/update_destination_command.go:33–117  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

31}
32
33func (cmd UpdateDestinationCommand) Execute(args []string) error {
34 err := cmd.SharedActor.CheckTarget(true, true)
35 if err != nil {
36 return err
37 }
38
39 user, err := cmd.Actor.GetCurrentUser()
40 if err != nil {
41 return err
42 }
43
44 domain, warnings, err := cmd.Actor.GetDomainByName(cmd.RequiredArgs.Domain)
45 cmd.UI.DisplayWarnings(warnings)
46 if err != nil {
47 return err
48 }
49
50 spaceGUID := cmd.Config.TargetedSpace().GUID
51 app, warnings, err := cmd.Actor.GetApplicationByNameAndSpace(cmd.RequiredArgs.App, spaceGUID)
52 cmd.UI.DisplayWarnings(warnings)
53 if err != nil {
54 return err
55 }
56
57 path := cmd.Path.Path
58 route, warnings, err := cmd.Actor.GetRouteByAttributes(domain, cmd.Hostname, path, 0)
59 cmd.UI.DisplayWarnings(warnings)
60 url := desiredURL(domain.Name, cmd.Hostname, path, 0)
61 if err != nil {
62 if _, ok := err.(actionerror.RouteNotFoundError); ok {
63 cmd.UI.DisplayText("Route to be updated does not exist.")
64 return err
65 }
66 return err
67 }
68
69 dest, err := cmd.Actor.GetRouteDestinationByAppGUID(route, app.GUID)
70 if err != nil {
71 if _, ok := err.(actionerror.RouteDestinationNotFoundError); !ok {
72 cmd.UI.DisplayText("Route's destination to be updated does not exist.")
73 return err
74 }
75 }
76
77 if cmd.AppProtocol == "" {
78 cmd.AppProtocol = "http1"
79 }
80
81 if cmd.AppProtocol == "tcp" {
82 return errors.New("Destination protocol must be 'http1' or 'http2'")
83 }
84
85 if dest.Protocol == cmd.AppProtocol {
86 cmd.UI.DisplayText(" App '{{ .AppName }}' is already using '{{ .AppProtocol }}'. Nothing has been updated", map[string]interface{}{
87 "AppName": cmd.RequiredArgs.App,
88 "AppProtocol": cmd.AppProtocol,
89 })
90 cmd.UI.DisplayOK()

Callers

nothing calls this directly

Calls 14

desiredURLFunction · 0.85
CheckTargetMethod · 0.65
GetCurrentUserMethod · 0.65
GetDomainByNameMethod · 0.65
DisplayWarningsMethod · 0.65
TargetedSpaceMethod · 0.65
GetRouteByAttributesMethod · 0.65
DisplayTextMethod · 0.65
DisplayOKMethod · 0.65
DisplayTextWithFlavorMethod · 0.65

Tested by

no test coverage detected