/
list_apps.go
55 lines (47 loc) · 1.27 KB
/
list_apps.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package command
import (
"fmt"
"github.com/TimeIncOSS/ape-dev-rt/commons"
"github.com/TimeIncOSS/ape-dev-rt/deploymentstate"
)
var whitelistedOutputs = map[string]bool{
"app": true,
"lb_fqdn": true,
}
func ListApps(c *commons.Context) error {
ds, ok := c.CliContext.App.Metadata["ds"].(*deploymentstate.DeploymentState)
if !ok {
return fmt.Errorf("Unable to find Deployment State in metadata")
}
fmt.Printf("%s Listing apps from the main deploymentstate backend.\n", colour.boldWhite("Note:"))
apps, err := ds.ListApplications()
if err != nil {
return err
}
if len(apps) == 0 {
fmt.Println(colour.boldWhite("No applications found."), " Did you eat them all?! :o\n")
return nil
}
for _, a := range apps {
if a.IsActive {
fmt.Printf("%s", colour.boldWhite(a.Name))
legacySuffix := ""
if a.UseCentralGitRepo {
legacySuffix = ", " + colour.boldYellow("uses central git repo")
}
fmt.Printf(" (RT %s%s)\n", a.LastRtVersion, legacySuffix)
if a.InfraOutputs != nil && len(a.InfraOutputs) > 0 {
for k, v := range a.InfraOutputs {
if whitelistedOutputs[k] {
fmt.Printf(" - %s: %s\n", k, v)
}
}
}
} else {
fmt.Printf("%s (%s)", a.Name, colour.red("inactive"))
}
fmt.Println("")
}
fmt.Println("")
return nil
}