forked from toolshed/abra
refactor!: drop version, show versions in ps
See coop-cloud/organising#526 See coop-cloud/organising#502
This commit is contained in:
@ -50,23 +50,30 @@ var appPsCommand = cli.Command{
|
||||
log.Fatalf("%s is not deployed?", app.Name)
|
||||
}
|
||||
|
||||
chaosVersion := "false"
|
||||
statuses, err := appPkg.GetAppStatuses([]appPkg.App{app}, true)
|
||||
if statusMeta, ok := statuses[app.StackName()]; ok {
|
||||
if _, exists := statusMeta["chaos"]; !exists {
|
||||
isChaos, exists := statusMeta["chaos"]
|
||||
if exists && isChaos == "false" {
|
||||
if err := app.Recipe.EnsureVersion(deployedVersion); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
} else {
|
||||
chaosVersion, err = app.Recipe.ChaosVersion()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
showPSOutput(app, cl)
|
||||
showPSOutput(app, cl, deployedVersion, chaosVersion)
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
// showPSOutput renders ps output.
|
||||
func showPSOutput(app appPkg.App, cl *dockerClient.Client) {
|
||||
func showPSOutput(app appPkg.App, cl *dockerClient.Client, deployedVersion, chaosVersion string) {
|
||||
r := recipe.Get(app.Name)
|
||||
composeFiles, err := r.GetComposeFiles(app.Env)
|
||||
if err != nil {
|
||||
@ -101,6 +108,8 @@ func showPSOutput(app appPkg.App, cl *dockerClient.Client) {
|
||||
var containerStats map[string]string
|
||||
if len(containers) == 0 {
|
||||
containerStats = map[string]string{
|
||||
"version": deployedVersion,
|
||||
"chaos": chaosVersion,
|
||||
"service": service.Name,
|
||||
"image": "unknown",
|
||||
"created": "unknown",
|
||||
@ -111,6 +120,8 @@ func showPSOutput(app appPkg.App, cl *dockerClient.Client) {
|
||||
} else {
|
||||
container := containers[0]
|
||||
containerStats = map[string]string{
|
||||
"version": deployedVersion,
|
||||
"chaos": chaosVersion,
|
||||
"service": abraService.ContainerToServiceName(container.Names, app.StackName()),
|
||||
"image": formatter.RemoveSha(container.Image),
|
||||
"created": formatter.HumanDuration(container.Created),
|
||||
@ -123,6 +134,8 @@ func showPSOutput(app appPkg.App, cl *dockerClient.Client) {
|
||||
allContainerStats[containerStats["service"]] = containerStats
|
||||
|
||||
tablerow := []string{
|
||||
deployedVersion,
|
||||
chaosVersion,
|
||||
containerStats["service"],
|
||||
containerStats["image"],
|
||||
containerStats["created"],
|
||||
@ -145,10 +158,11 @@ func showPSOutput(app appPkg.App, cl *dockerClient.Client) {
|
||||
return
|
||||
}
|
||||
|
||||
tableCol := []string{"service", "image", "created", "status", "state", "ports"}
|
||||
tableCol := []string{"version", "chaos", "service", "image", "created", "status", "state", "ports"}
|
||||
table := formatter.CreateTable(tableCol)
|
||||
for _, row := range tablerows {
|
||||
table.Append(row)
|
||||
}
|
||||
table.SetAutoMergeCellsByColumnIndex([]int{0, 1})
|
||||
table.Render()
|
||||
}
|
||||
|
Reference in New Issue
Block a user