(app models.Application, orgName, spaceName string)
| 101 | } |
| 102 | |
| 103 | func (cmd *ShowApp) ShowApp(app models.Application, orgName, spaceName string) error { |
| 104 | cmd.ui.Say(T("Showing health and status for app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...", |
| 105 | map[string]interface{}{ |
| 106 | "AppName": terminal.EntityNameColor(app.Name), |
| 107 | "OrgName": terminal.EntityNameColor(orgName), |
| 108 | "SpaceName": terminal.EntityNameColor(spaceName), |
| 109 | "Username": terminal.EntityNameColor(cmd.config.Username())})) |
| 110 | |
| 111 | application, err := cmd.appSummaryRepo.GetSummary(app.GUID) |
| 112 | |
| 113 | appIsStopped := (application.State == "stopped") |
| 114 | if assertionErr, ok := err.(errors.HTTPError); ok { |
| 115 | if assertionErr.ErrorCode() == errors.InstancesError || assertionErr.ErrorCode() == errors.NotStaged { |
| 116 | appIsStopped = true |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | if err != nil && !appIsStopped { |
| 121 | return err |
| 122 | } |
| 123 | |
| 124 | var instances []models.AppInstanceFields |
| 125 | instances, err = cmd.appInstancesRepo.GetInstances(app.GUID) |
| 126 | if err != nil && !appIsStopped { |
| 127 | return err |
| 128 | } |
| 129 | |
| 130 | if cmd.pluginCall { |
| 131 | cmd.populatePluginModel(application, app.Stack, instances) |
| 132 | } |
| 133 | |
| 134 | cmd.ui.Ok() |
| 135 | cmd.ui.Say("\n%s %s", terminal.HeaderColor(T("requested state:")), uihelpers.ColoredAppState(application.ApplicationFields)) |
| 136 | cmd.ui.Say("%s %s", terminal.HeaderColor(T("instances:")), uihelpers.ColoredAppInstances(application.ApplicationFields)) |
| 137 | |
| 138 | cmd.ui.Say(T("{{.Usage}} {{.FormattedMemory}} x {{.InstanceCount}} instances", |
| 139 | map[string]interface{}{ |
| 140 | "Usage": terminal.HeaderColor(T("usage:")), |
| 141 | "FormattedMemory": formatters.ByteSize(application.Memory * formatters.MEGABYTE), |
| 142 | "InstanceCount": application.InstanceCount})) |
| 143 | |
| 144 | var urls []string |
| 145 | for _, route := range application.Routes { |
| 146 | urls = append(urls, route.URL()) |
| 147 | } |
| 148 | |
| 149 | cmd.ui.Say("%s %s", terminal.HeaderColor(T("urls:")), strings.Join(urls, ", ")) |
| 150 | var lastUpdated string |
| 151 | if application.PackageUpdatedAt != nil { |
| 152 | lastUpdated = application.PackageUpdatedAt.Format("Mon Jan 2 15:04:05 MST 2006") |
| 153 | } else { |
| 154 | lastUpdated = "unknown" |
| 155 | } |
| 156 | cmd.ui.Say("%s %s", terminal.HeaderColor(T("last uploaded:")), lastUpdated) |
| 157 | |
| 158 | appStack, err := cmd.stackRepo.FindByGUID(application.ApplicationFields.StackGUID) |
| 159 | if appStack.Name != "" && err == nil { |
| 160 | cmd.ui.Say("%s %s", terminal.HeaderColor(T("stack:")), appStack.Name) |
no test coverage detected