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

Method Execute

command/v7/revisions_command.go:27–124  ·  view source on GitHub ↗
(_ []string)

Source from the content-addressed store, hash-verified

25}
26
27func (cmd RevisionsCommand) Execute(_ []string) error {
28 err := cmd.SharedActor.CheckTarget(true, true)
29 if err != nil {
30 return err
31 }
32
33 user, err := cmd.Actor.GetCurrentUser()
34 if err != nil {
35 return err
36 }
37
38 appName := cmd.RequiredArgs.AppName
39 cmd.UI.DisplayTextWithFlavor("Getting revisions for app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...", map[string]interface{}{
40 "AppName": appName,
41 "OrgName": cmd.Config.TargetedOrganization().Name,
42 "SpaceName": cmd.Config.TargetedSpace().Name,
43 "Username": user.Name,
44 })
45
46 app, warnings, err := cmd.Actor.GetApplicationByNameAndSpace(appName, cmd.Config.TargetedSpace().GUID)
47 cmd.UI.DisplayWarnings(warnings)
48 if err != nil {
49 return err
50 }
51
52 appGUID := app.GUID
53 revisionsFeature, warnings, err := cmd.Actor.GetAppFeature(appGUID, "revisions")
54 cmd.UI.DisplayWarnings(warnings)
55 if err != nil {
56 return err
57 }
58
59 if !revisionsFeature.Enabled {
60 cmd.UI.DisplayWarning("Warning: Revisions for app '{{.AppName}}' are disabled. Updates to the app will not create new revisions.",
61 map[string]interface{}{
62 "AppName": appName,
63 })
64 }
65
66 if app.Stopped() {
67 cmd.UI.DisplayNewline()
68 cmd.UI.DisplayText(fmt.Sprintf("Info: this app is in a stopped state. It is not possible to determine which revision is currently deployed."))
69 }
70
71 cmd.UI.DisplayNewline()
72
73 revisions, warnings, err := cmd.Actor.GetRevisionsByApplicationNameAndSpace(
74 appName,
75 cmd.Config.TargetedSpace().GUID,
76 )
77 cmd.UI.DisplayWarnings(warnings)
78 if err != nil {
79 return err
80 }
81
82 if len(revisions) == 0 {
83 cmd.UI.DisplayText("No revisions found")
84 return nil

Callers

nothing calls this directly

Calls 15

StoppedMethod · 0.80
CheckTargetMethod · 0.65
GetCurrentUserMethod · 0.65
DisplayTextWithFlavorMethod · 0.65
TargetedOrganizationMethod · 0.65
TargetedSpaceMethod · 0.65
DisplayWarningsMethod · 0.65
GetAppFeatureMethod · 0.65
DisplayWarningMethod · 0.65
DisplayNewlineMethod · 0.65

Tested by

no test coverage detected