Restore `Project` is ps json output

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2023-11-24 10:19:34 +01:00 committed by Nicolas De loof
parent ba24a656bf
commit a1de0b96c3
2 changed files with 8 additions and 0 deletions

View File

@ -33,6 +33,7 @@ const (
defaultContainerTableFormat = "table {{.Name}}\t{{.Image}}\t{{.Command}}\t{{.Service}}\t{{.RunningFor}}\t{{.Status}}\t{{.Ports}}" defaultContainerTableFormat = "table {{.Name}}\t{{.Image}}\t{{.Command}}\t{{.Service}}\t{{.RunningFor}}\t{{.Status}}\t{{.Ports}}"
nameHeader = "NAME" nameHeader = "NAME"
projectHeader = "PROJECT"
serviceHeader = "SERVICE" serviceHeader = "SERVICE"
commandHeader = "COMMAND" commandHeader = "COMMAND"
runningForHeader = "CREATED" runningForHeader = "CREATED"
@ -112,6 +113,7 @@ func NewContainerContext() *ContainerContext {
containerCtx.Header = formatter.SubHeaderContext{ containerCtx.Header = formatter.SubHeaderContext{
"ID": formatter.ContainerIDHeader, "ID": formatter.ContainerIDHeader,
"Name": nameHeader, "Name": nameHeader,
"Project": projectHeader,
"Service": serviceHeader, "Service": serviceHeader,
"Image": formatter.ImageHeader, "Image": formatter.ImageHeader,
"Command": commandHeader, "Command": commandHeader,
@ -164,6 +166,10 @@ func (c *ContainerContext) Service() string {
return c.c.Service return c.c.Service
} }
func (c *ContainerContext) Project() string {
return c.c.Project
}
func (c *ContainerContext) Image() string { func (c *ContainerContext) Image() string {
return c.c.Image return c.c.Image
} }

View File

@ -64,6 +64,7 @@ func TestPs(t *testing.T) {
"--format", "json") "--format", "json")
type element struct { type element struct {
Name string Name string
Project string
Publishers api.PortPublishers Publishers api.PortPublishers
} }
var output []element var output []element
@ -78,6 +79,7 @@ func TestPs(t *testing.T) {
count := 0 count := 0
assert.Equal(t, 2, len(output)) assert.Equal(t, 2, len(output))
for _, service := range output { for _, service := range output {
assert.Equal(t, projectName, service.Project)
publishers := service.Publishers publishers := service.Publishers
if service.Name == "e2e-ps-busybox-1" { if service.Name == "e2e-ps-busybox-1" {
assert.Equal(t, 1, len(publishers)) assert.Equal(t, 1, len(publishers))