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

Method Execute

command/v7/upgrade_service_command.go:20–72  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

18}
19
20func (cmd UpgradeServiceCommand) Execute(args []string) error {
21 if err := cmd.SharedActor.CheckTarget(true, true); err != nil {
22 return err
23 }
24
25 if !cmd.Force {
26 upgrade, err := cmd.displayPrompt()
27 if err != nil {
28 return err
29 }
30
31 if !upgrade {
32 cmd.UI.DisplayText("Upgrade cancelled")
33 return nil
34 }
35 }
36
37 if err := cmd.displayEvent(); err != nil {
38 return err
39 }
40
41 serviceInstanceName := string(cmd.RequiredArgs.ServiceInstance)
42
43 stream, warnings, actorError := cmd.Actor.UpgradeManagedServiceInstance(
44 serviceInstanceName,
45 cmd.Config.TargetedSpace().GUID,
46 )
47 cmd.UI.DisplayWarnings(warnings)
48
49 switch actorError.(type) {
50 case nil:
51 case actionerror.ServiceInstanceUpgradeNotAvailableError:
52 cmd.UI.DisplayText(actorError.Error())
53 cmd.UI.DisplayOK()
54 case actionerror.ServiceInstanceNotFoundError:
55 return translatableerror.ServiceInstanceNotFoundError{Name: serviceInstanceName}
56 default:
57 return actorError
58 }
59
60 complete, err := shared.WaitForResult(stream, cmd.UI, cmd.Wait)
61 switch {
62 case err != nil:
63 return err
64 case complete:
65 cmd.UI.DisplayTextWithFlavor("Upgrade of service instance {{.ServiceInstanceName}} complete.", cmd.serviceInstanceName())
66 default:
67 cmd.UI.DisplayTextWithFlavor("Upgrade in progress. Use 'cf services' or 'cf service {{.ServiceInstanceName}}' to check operation status.", cmd.serviceInstanceName())
68 }
69
70 cmd.UI.DisplayOK()
71 return nil
72}
73
74func (cmd UpgradeServiceCommand) Usage() string {
75 return "CF_NAME upgrade-service SERVICE_INSTANCE"

Callers

nothing calls this directly

Calls 12

displayPromptMethod · 0.95
displayEventMethod · 0.95
serviceInstanceNameMethod · 0.95
WaitForResultFunction · 0.92
CheckTargetMethod · 0.65
DisplayTextMethod · 0.65
TargetedSpaceMethod · 0.65
DisplayWarningsMethod · 0.65
ErrorMethod · 0.65
DisplayOKMethod · 0.65
DisplayTextWithFlavorMethod · 0.65

Tested by

no test coverage detected