feat: service name in ps output
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
95d385c420
commit
866cdd1f29
|
@ -9,6 +9,7 @@ import (
|
||||||
"coopcloud.tech/abra/pkg/client"
|
"coopcloud.tech/abra/pkg/client"
|
||||||
"coopcloud.tech/abra/pkg/config"
|
"coopcloud.tech/abra/pkg/config"
|
||||||
"coopcloud.tech/abra/pkg/formatter"
|
"coopcloud.tech/abra/pkg/formatter"
|
||||||
|
"coopcloud.tech/abra/pkg/service"
|
||||||
stack "coopcloud.tech/abra/pkg/upstream/stack"
|
stack "coopcloud.tech/abra/pkg/upstream/stack"
|
||||||
"github.com/buger/goterm"
|
"github.com/buger/goterm"
|
||||||
dockerFormatter "github.com/docker/cli/cli/command/formatter"
|
dockerFormatter "github.com/docker/cli/cli/command/formatter"
|
||||||
|
@ -70,7 +71,7 @@ func showPSOutput(c *cli.Context, app config.App, cl *dockerClient.Client) {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
tableCol := []string{"image", "created", "status", "state", "ports"}
|
tableCol := []string{"service name", "image", "created", "status", "state", "ports"}
|
||||||
table := formatter.CreateTable(tableCol)
|
table := formatter.CreateTable(tableCol)
|
||||||
|
|
||||||
for _, container := range containers {
|
for _, container := range containers {
|
||||||
|
@ -81,6 +82,7 @@ func showPSOutput(c *cli.Context, app config.App, cl *dockerClient.Client) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tableRow := []string{
|
tableRow := []string{
|
||||||
|
service.ContainerToServiceName(container.Names, app.StackName()),
|
||||||
formatter.RemoveSha(container.Image),
|
formatter.RemoveSha(container.Image),
|
||||||
formatter.HumanDuration(container.Created),
|
formatter.HumanDuration(container.Created),
|
||||||
container.Status,
|
container.Status,
|
||||||
|
|
|
@ -67,3 +67,12 @@ func GetService(c context.Context, cl *client.Client, filters filters.Args, prom
|
||||||
|
|
||||||
return services[0], nil
|
return services[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContainerToServiceName converts a container name to a service name.
|
||||||
|
func ContainerToServiceName(containerNames []string, stackName string) string {
|
||||||
|
containerName := strings.Join(containerNames, "")
|
||||||
|
trimmed := strings.TrimPrefix(containerName, "/")
|
||||||
|
stackNameServiceName := strings.Split(trimmed, ".")[0]
|
||||||
|
splitter := fmt.Sprintf("%s_", stackName)
|
||||||
|
return strings.Split(stackNameServiceName, splitter)[1]
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue