(positionalArgs []string, dsHost string, flags *flag.FlagSet, cfTarget util.CloudFoundryTarget)
| 57 | } |
| 58 | |
| 59 | func (c *MtaCommand) executeInternal(positionalArgs []string, dsHost string, flags *flag.FlagSet, cfTarget util.CloudFoundryTarget) ExecutionStatus { |
| 60 | mtaID := positionalArgs[0] |
| 61 | // Print initial message |
| 62 | ui.Say("Showing health and status for multi-target app %s in org %s / space %s as %s...", |
| 63 | terminal.EntityNameColor(mtaID), terminal.EntityNameColor(cfTarget.Org.Name), |
| 64 | terminal.EntityNameColor(cfTarget.Space.Name), terminal.EntityNameColor(cfTarget.Username)) |
| 65 | |
| 66 | // Create new REST client |
| 67 | mtaV2Client := c.NewMtaV2Client(dsHost, cfTarget) |
| 68 | |
| 69 | namespace := strings.TrimSpace(GetStringOpt(namespaceOpt, flags)) |
| 70 | // Get the MTA |
| 71 | mtas, err := mtaV2Client.GetMtasForThisSpace(&mtaID, &namespace) |
| 72 | if err != nil { |
| 73 | ce, ok := err.(*baseclient.ClientError) |
| 74 | if ok && ce.Code == 404 && strings.Contains(fmt.Sprint(ce.Description), mtaID) { |
| 75 | ui.Failed("Multi-target app %s not found", terminal.EntityNameColor(mtaID)) |
| 76 | return Failure |
| 77 | } |
| 78 | ui.Failed("Could not get multi-target app %s: %s", terminal.EntityNameColor(mtaID), baseclient.NewClientError(err)) |
| 79 | return Failure |
| 80 | |
| 81 | } |
| 82 | if len(mtas) > 1 { |
| 83 | ui.Failed("Multiple multi-target apps exist for name %s, please enter namespace", terminal.EntityNameColor(mtaID)) |
| 84 | return Failure |
| 85 | } |
| 86 | mta := mtas[0] |
| 87 | ui.Ok() |
| 88 | |
| 89 | // Display information about all apps and services |
| 90 | ui.Say("Version: %s", util.GetMtaVersionAsString(mta)) |
| 91 | ui.Say("Namespace: %s", mta.Metadata.Namespace) |
| 92 | ui.Say("\nApps:") |
| 93 | |
| 94 | apps, err := c.CfClient.GetApplications(mta.Metadata.ID, mta.Metadata.Namespace, cfTarget.Space.Guid) |
| 95 | if err != nil { |
| 96 | ui.Failed("Could not get apps: %s", err) |
| 97 | return Failure |
| 98 | } |
| 99 | |
| 100 | table := ui.Table([]string{"name", "requested state", "instances", "memory", "disk", "urls"}) |
| 101 | |
| 102 | for _, app := range apps { |
| 103 | processes, err := c.CfClient.GetAppProcessStatistics(app.Guid) |
| 104 | if err != nil { |
| 105 | ui.Failed("Could not get app %q process statistics: %s", app.Name, err) |
| 106 | return Failure |
| 107 | } |
| 108 | |
| 109 | routes, err := c.CfClient.GetApplicationRoutes(app.Guid) |
| 110 | if err != nil { |
| 111 | ui.Failed("Could not get app %q routes: %s", app.Name, err) |
| 112 | return Failure |
| 113 | } |
| 114 | |
| 115 | memory := int64(0) |
| 116 | disk := int64(0) |
nothing calls this directly
no test coverage detected