(serviceInstanceWithDetails v7action.ServiceInstanceDetails)
| 233 | } |
| 234 | |
| 235 | func (cmd ServiceCommand) displayBoundApps(serviceInstanceWithDetails v7action.ServiceInstanceDetails) { |
| 236 | cmd.UI.DisplayText("Showing bound apps:") |
| 237 | |
| 238 | if len(serviceInstanceWithDetails.BoundApps) == 0 { |
| 239 | cmd.UI.DisplayText(indent + "There are no bound apps for this service instance.") |
| 240 | cmd.UI.DisplayNewline() |
| 241 | return |
| 242 | } |
| 243 | |
| 244 | table := [][]string{{"name", "binding name", "status", "message", "guid", "created_at"}} |
| 245 | |
| 246 | bindings := serviceInstanceWithDetails.BoundApps |
| 247 | // sort by app name, then by created at descending |
| 248 | sort.Slice(bindings, func(i, j int) bool { |
| 249 | if bindings[i].AppName == bindings[j].AppName { |
| 250 | return bindings[i].CreatedAt > bindings[j].CreatedAt |
| 251 | } |
| 252 | return bindings[i].AppName < bindings[j].AppName |
| 253 | }) |
| 254 | |
| 255 | for _, app := range bindings { |
| 256 | table = append(table, []string{ |
| 257 | app.AppName, |
| 258 | app.Name, |
| 259 | fmt.Sprintf("%s %s", app.LastOperation.Type, app.LastOperation.State), |
| 260 | app.LastOperation.Description, |
| 261 | app.GUID, |
| 262 | app.CreatedAt, |
| 263 | }) |
| 264 | } |
| 265 | |
| 266 | cmd.UI.DisplayTableWithHeader(indent, table, ui.DefaultTableSpacePadding) |
| 267 | cmd.UI.DisplayNewline() |
| 268 | } |
no test coverage detected