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}}"
nameHeader = "NAME"
projectHeader = "PROJECT"
serviceHeader = "SERVICE"
commandHeader = "COMMAND"
runningForHeader = "CREATED"
@ -112,6 +113,7 @@ func NewContainerContext() *ContainerContext {
containerCtx.Header = formatter.SubHeaderContext{
"ID": formatter.ContainerIDHeader,
"Name": nameHeader,
"Project": projectHeader,
"Service": serviceHeader,
"Image": formatter.ImageHeader,
"Command": commandHeader,
@ -164,6 +166,10 @@ func (c *ContainerContext) Service() string {
return c.c.Service
}
func (c *ContainerContext) Project() string {
return c.c.Project
}
func (c *ContainerContext) Image() string {
return c.c.Image
}

View File

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