Merge pull request #347 from docker/inspect_platform

Add ”Platform” in docker inspect result, showing container OS
This commit is contained in:
Guillaume Tardif 2020-07-06 17:13:08 +02:00 committed by GitHub
commit b1d923d5a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 8 deletions

View File

@ -327,6 +327,7 @@ func ContainerGroupToContainer(containerID string, cg containerinstance.Containe
if cc.InstanceView != nil && cc.InstanceView.CurrentState != nil {
status = *cc.InstanceView.CurrentState.State
}
platform := string(cg.OsType)
c := containers.Container{
ID: containerID,
@ -341,6 +342,7 @@ func ContainerGroupToContainer(containerID string, cg containerinstance.Containe
PidsLimit: 0,
Labels: nil,
Ports: ToPorts(cg.IPAddress, *cc.Ports),
Platform: platform,
}
return c, nil

View File

@ -62,6 +62,7 @@ func (suite *ConvertTestSuite) TestContainerGroupToContainer() {
}},
IP: to.StringPtr("42.42.42.42"),
},
OsType: "Linux",
},
}
myContainer := containerinstance.Container{
@ -95,6 +96,7 @@ func (suite *ConvertTestSuite) TestContainerGroupToContainer() {
Command: "mycommand",
CPULimit: 3,
MemoryLimit: 107374182,
Platform: "Linux",
Ports: []containers.Port{{
HostPort: uint32(80),
ContainerPort: uint32(80),

View File

@ -10,5 +10,6 @@
"PidsCurrent": 0,
"PidsLimit": 0,
"Labels": null,
"Ports": null
"Ports": null,
"Platform": "Linux"
}

View File

@ -37,6 +37,7 @@ type Container struct {
PidsLimit uint64
Labels []string
Ports []Port
Platform string
}
// Port represents a published port of a container

View File

@ -58,8 +58,9 @@ type containerService struct{}
func (cs *containerService) Inspect(ctx context.Context, id string) (containers.Container, error) {
return containers.Container{
ID: "id",
Image: "nginx",
ID: "id",
Image: "nginx",
Platform: "Linux",
}, nil
}

View File

@ -88,10 +88,11 @@ func (ms *local) Inspect(ctx context.Context, id string) (containers.Container,
}
return containers.Container{
ID: stringid.TruncateID(c.ID),
Status: status,
Image: c.Image,
Command: command,
ID: stringid.TruncateID(c.ID),
Status: status,
Image: c.Image,
Command: command,
Platform: c.Platform,
}, nil
}

View File

@ -10,5 +10,6 @@
"PidsCurrent": 0,
"PidsLimit": 0,
"Labels": null,
"Ports": null
"Ports": null,
"Platform": "Linux"
}