forked from toolshed/abra
WIP: app status listing using concurrency
This being my first time using goroutines, it is pretty messy but the idea has been shown to be workable! We can concurrently look up multiple contexts for a much faster response time especially when using multiple servers. Remaining TODOs are: - [ ] Get proper status reporting (deployed/inactive/unknown) - [ ] Error handling (especially when missing contexts) - [ ] Refactor and tidy
This commit is contained in:
26
cli/app.go
26
cli/app.go
@ -59,27 +59,35 @@ var appListCommand = &cli.Command{
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
apps, err := config.GetApps(appFiles)
|
||||
sort.Sort(config.ByServerAndType(apps))
|
||||
|
||||
statuses := map[string]string{}
|
||||
tableCol := []string{"Server", "Type", "Domain"}
|
||||
if Status {
|
||||
tableCol = []string{"Server", "Type", "Domain", "Status"}
|
||||
tableCol = append(tableCol, "Status")
|
||||
statuses, err = config.GetAppStatuses(appFiles)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
table := createTable(tableCol)
|
||||
table.SetAutoMergeCellsByColumnIndex([]int{0})
|
||||
|
||||
apps, err := config.GetApps(appFiles)
|
||||
sort.Sort(config.ByServerAndType(apps))
|
||||
for _, app := range apps {
|
||||
var tableRow []string
|
||||
if app.Type == Type || Type == "" {
|
||||
// If type flag is set, check for it, if not, Type == ""
|
||||
tableRow = []string{app.File.Server, app.Type, app.Domain}
|
||||
}
|
||||
if Status {
|
||||
status, err := app.GetStatus()
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
if Status {
|
||||
stackName := strings.ReplaceAll(app.Name, ".", "_")
|
||||
if status, ok := statuses[stackName]; ok {
|
||||
tableRow = append(tableRow, status)
|
||||
} else {
|
||||
tableRow = append(tableRow, "unknown")
|
||||
}
|
||||
}
|
||||
tableRow = []string{app.File.Server, app.Type, app.Domain, status}
|
||||
}
|
||||
table.Append(tableRow)
|
||||
}
|
||||
|
Reference in New Issue
Block a user