Skip to content

Commit

Permalink
feature: add rest fields in container inspect response
Browse files Browse the repository at this point in the history
Signed-off-by: Allen Sun <allensun.shl@alibaba-inc.com>
  • Loading branch information
allencloud authored and HusterWan committed Dec 25, 2018
1 parent 684c6e5 commit b34d318
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 12 deletions.
8 changes: 8 additions & 0 deletions apis/server/container_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ func (s *Server) getContainer(ctx context.Context, rw http.ResponseWriter, req *
},
Mounts: mounts,
NetworkSettings: c.NetworkSettings,
Path: c.Path,
Args: c.Args,
ResolvConfPath: c.ResolvConfPath,
HostnamePath: c.HostnamePath,
HostsPath: c.HostsPath,
Driver: c.Driver,
MountLabel: c.MountLabel,
ProcessLabel: c.ProcessLabel,
}

return EncodeResponse(rw, http.StatusOK, container)
Expand Down
11 changes: 10 additions & 1 deletion apis/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3392,24 +3392,33 @@ definitions:
description: "The container's image"
type: "string"
ResolvConfPath:
description: "the path of container's resolvConf file on host."
type: "string"
HostnamePath:
HostnamePath:
description: "the path of container's hostname file on host."
type: "string"
HostsPath:
description: "the path of container's hosts file on host."
type: "string"
LogPath:
description: "the path of container's log file on host."
type: "string"
Name:
description: "name of the created container."
type: "string"
RestartCount:
description: "the container's restart time"
type: "integer"
Driver:
description: ""
type: "string"
MountLabel:
description: "MountLabel contains the options for the 'mount' command."
type: "string"
ProcessLabel:
type: "string"
AppArmorProfile:
description: "AppArmorProfile are specific for AppArmor to Unix platforms"
type: "string"
ExecIDs:
description: "exec ids of container"
Expand Down
16 changes: 8 additions & 8 deletions apis/types/container_json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apis/types/resources.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions test/cli_inspect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,22 @@ func (suite *PouchInspectSuite) TestInspectCreateAndStartedFormat(c *check.C) {
res = command.PouchRun("start", name)
res.Assert(c, icmd.Success)

// Inspect LogPath, LogPath should not be empty after container's start.
// by default, the container has log type of json-file.
// Inspect LogPath, HostnamePath, HostsPath, ResolvConfPath
output = command.PouchRun("inspect", "-f", "{{.LogPath}}", name).Stdout()
expectedLogPath := fmt.Sprintf(rootDir+"/containers/%s/json.log", containerID)
c.Assert(strings.TrimSpace(output), check.Equals, expectedLogPath)

output = command.PouchRun("inspect", "-f", "{{.ResolvConfPath}}", name).Stdout()
expectedLogPath = fmt.Sprintf(rootDir+"/containers/%s/resolv.conf", containerID)
c.Assert(strings.TrimSpace(output), check.Equals, expectedLogPath)

output = command.PouchRun("inspect", "-f", "{{.HostnamePath}}", name).Stdout()
expectedLogPath = fmt.Sprintf(rootDir+"/containers/%s/hostname", containerID)
c.Assert(strings.TrimSpace(output), check.Equals, expectedLogPath)

output = command.PouchRun("inspect", "-f", "{{.HostsPath}}", name).Stdout()
expectedLogPath = fmt.Sprintf(rootDir+"/containers/%s/hosts", containerID)
c.Assert(strings.TrimSpace(output), check.Equals, expectedLogPath)
}

// TestInspectWrongFormat is to verify using wrong format flag of inspect command.
Expand Down

0 comments on commit b34d318

Please sign in to comment.