Skip to content

Commit

Permalink
added short id for table printer
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt committed Jun 15, 2021
1 parent 29134ba commit bee3dab
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func printContainerInspect(c *clab.CLab, containers []types.GenericContainer, br
IPv4Address: getContainerIPv4(cont, bridgeName),
IPv6Address: getContainerIPv6(cont, bridgeName),
}
cdet.ContainerID = cont.ID
cdet.ContainerID = cont.ShortID

if len(cont.Names) > 0 {
cdet.Name = strings.TrimLeft(cont.Names[0], "/")
Expand Down
1 change: 1 addition & 0 deletions runtime/containerd/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ func (c *ContainerdRuntime) produceGenericContainerList(ctx context.Context, inp

ctr.Names = []string{i.ID()}
ctr.ID = i.ID()
ctr.ShortID = ctr.ID
ctr.Image = info.Image
ctr.Labels = info.Labels

Expand Down
13 changes: 7 additions & 6 deletions runtime/docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,13 @@ func (c *DockerRuntime) produceGenericContainerList(inputContainers []dockerType

for _, i := range inputContainers {
ctr := types.GenericContainer{
Names: i.Names,
ID: i.ID,
Image: i.Image,
State: i.State,
Status: i.Status,
Labels: i.Labels,
Names: i.Names,
ID: i.ID,
ShortID: i.ID[:12],
Image: i.Image,
State: i.State,
Status: i.Status,
Labels: i.Labels,
NetworkSettings: &types.GenericMgmtIPs{
Set: false,
},
Expand Down
1 change: 1 addition & 0 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func (node *Node) GenerateConfig(dst, defaultTemplatePath string) error {
type GenericContainer struct {
Names []string
ID string
ShortID string // trimmed ID for display purposes
Image string
State string
Status string
Expand Down

0 comments on commit bee3dab

Please sign in to comment.