From 7296290408676eba2a213608524f5eb99186e148 Mon Sep 17 00:00:00 2001 From: Guillaume Tardif Date: Mon, 6 Jul 2020 12:15:07 +0200 Subject: [PATCH] =?UTF-8?q?Add=20=E2=80=9DPlatform=E2=80=9D=20in=20docker?= =?UTF-8?q?=20inspect=20result,=20showing=20container=20OS=20(this=20field?= =?UTF-8?q?=20is=20used=20by=20VSCode)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- azure/convert/convert.go | 2 ++ azure/convert/convert_test.go | 2 ++ cli/cmd/testdata/inspect-out-id.golden | 3 ++- containers/api.go | 1 + example/backend.go | 5 +++-- local/backend.go | 9 +++++---- tests/e2e/testdata/inspect-id.golden | 3 ++- 7 files changed, 17 insertions(+), 8 deletions(-) diff --git a/azure/convert/convert.go b/azure/convert/convert.go index c4953a3f9..086e7f943 100644 --- a/azure/convert/convert.go +++ b/azure/convert/convert.go @@ -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 diff --git a/azure/convert/convert_test.go b/azure/convert/convert_test.go index 72841d888..a69b8a391 100644 --- a/azure/convert/convert_test.go +++ b/azure/convert/convert_test.go @@ -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), diff --git a/cli/cmd/testdata/inspect-out-id.golden b/cli/cmd/testdata/inspect-out-id.golden index 9c245aca2..09020fb04 100644 --- a/cli/cmd/testdata/inspect-out-id.golden +++ b/cli/cmd/testdata/inspect-out-id.golden @@ -10,5 +10,6 @@ "PidsCurrent": 0, "PidsLimit": 0, "Labels": null, - "Ports": null + "Ports": null, + "Platform": "Linux" } diff --git a/containers/api.go b/containers/api.go index 87b2cdaf3..3697e484f 100644 --- a/containers/api.go +++ b/containers/api.go @@ -37,6 +37,7 @@ type Container struct { PidsLimit uint64 Labels []string Ports []Port + Platform string } // Port represents a published port of a container diff --git a/example/backend.go b/example/backend.go index c5da8bf1e..5232d73df 100644 --- a/example/backend.go +++ b/example/backend.go @@ -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 } diff --git a/local/backend.go b/local/backend.go index 6ceea4e1f..6b9090b74 100644 --- a/local/backend.go +++ b/local/backend.go @@ -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 } diff --git a/tests/e2e/testdata/inspect-id.golden b/tests/e2e/testdata/inspect-id.golden index 9c245aca2..09020fb04 100644 --- a/tests/e2e/testdata/inspect-id.golden +++ b/tests/e2e/testdata/inspect-id.golden @@ -10,5 +10,6 @@ "PidsCurrent": 0, "PidsLimit": 0, "Labels": null, - "Ports": null + "Ports": null, + "Platform": "Linux" }