mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-08-05 00:15:44 +00:00
Merge pull request #29168 from Honny1/fix-json-format
Fix inspect template `.HostIp` for Docker compatibility
This commit is contained in:
commit
5561e6c416
2 changed files with 19 additions and 0 deletions
|
|
@ -265,6 +265,12 @@ type InspectHostPort struct {
|
|||
HostPort string `json:"HostPort"`
|
||||
}
|
||||
|
||||
// HostIp allows Docker-compatible {{.HostIp}} access in Go templates.
|
||||
// See https://github.com/containers/podman/issues/29164
|
||||
func (hp InspectHostPort) HostIp() string {
|
||||
return hp.HostIP
|
||||
}
|
||||
|
||||
// InspectMount provides a record of a single mount in a container. It contains
|
||||
// fields for both named and normal volumes. Only user-specified volumes will be
|
||||
// included, and tmpfs volumes are not included even if the user specified them.
|
||||
|
|
|
|||
|
|
@ -107,6 +107,19 @@ var _ = Describe("Podman container inspect", func() {
|
|||
Expect(data[0].Config.Annotations[define.VolumesFromAnnotation]).To(Equal(volsctr))
|
||||
})
|
||||
|
||||
// https://github.com/containers/podman/issues/29164
|
||||
It("podman inspect supports docker-compatible HostIp in format template", func() {
|
||||
ctrName := "hostip-compat"
|
||||
session := podmanTest.Podman([]string{"create", "--name", ctrName, "-p", "127.0.0.1::8080/tcp", ALPINE})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
|
||||
inspect := podmanTest.Podman([]string{"inspect", "--format", `{{ (index (index .NetworkSettings.Ports "8080/tcp") 0).HostIp }}`, ctrName})
|
||||
inspect.WaitWithDefaultTimeout()
|
||||
Expect(inspect).Should(ExitCleanly())
|
||||
Expect(inspect.OutputToString()).To(Equal("127.0.0.1"))
|
||||
})
|
||||
|
||||
It("podman inspect hides secrets mounted to env", func() {
|
||||
secretName := "mysecret"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue