mirror of
https://github.com/containers/podman.git
synced 2025-06-10 17:48:29 +08:00
inspect image healthchecks
when a docker image has a defined healthcheck, it should be displayed with inspect. this is only valid for docker images as oci images are not aware of healthchecks. Fixes: #4799 Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
@ -1012,6 +1012,15 @@ func (i *Image) Inspect(ctx context.Context) (*inspect.ImageData, error) {
|
|||||||
History: ociv1Img.History,
|
History: ociv1Img.History,
|
||||||
NamesHistory: i.NamesHistory(),
|
NamesHistory: i.NamesHistory(),
|
||||||
}
|
}
|
||||||
|
if manifestType == manifest.DockerV2Schema2MediaType {
|
||||||
|
hc, err := i.GetHealthCheck(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if hc != nil {
|
||||||
|
data.HealthCheck = hc
|
||||||
|
}
|
||||||
|
}
|
||||||
return data, nil
|
return data, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package inspect
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/containers/image/v5/manifest"
|
||||||
"github.com/containers/libpod/libpod/driver"
|
"github.com/containers/libpod/libpod/driver"
|
||||||
"github.com/opencontainers/go-digest"
|
"github.com/opencontainers/go-digest"
|
||||||
"github.com/opencontainers/image-spec/specs-go/v1"
|
"github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
@ -32,6 +33,7 @@ type ImageData struct {
|
|||||||
User string `json:"User"`
|
User string `json:"User"`
|
||||||
History []v1.History `json:"History"`
|
History []v1.History `json:"History"`
|
||||||
NamesHistory []string `json:"NamesHistory"`
|
NamesHistory []string `json:"NamesHistory"`
|
||||||
|
HealthCheck *manifest.Schema2HealthConfig `json:"Healthcheck,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// RootFS holds the root fs information of an image
|
// RootFS holds the root fs information of an image
|
||||||
|
@ -164,4 +164,17 @@ var _ = Describe("Podman inspect", func() {
|
|||||||
Expect(inspectDst.ExitCode()).To(Equal(0))
|
Expect(inspectDst.ExitCode()).To(Equal(0))
|
||||||
Expect(inspectDst.OutputToString()).To(Equal("/test1"))
|
Expect(inspectDst.OutputToString()).To(Equal("/test1"))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("podman inspect shows healthcheck on docker image", func() {
|
||||||
|
pull := podmanTest.Podman([]string{"pull", healthcheck})
|
||||||
|
pull.WaitWithDefaultTimeout()
|
||||||
|
Expect(pull.ExitCode()).To(BeZero())
|
||||||
|
|
||||||
|
session := podmanTest.Podman([]string{"inspect", "--format=json", healthcheck})
|
||||||
|
session.WaitWithDefaultTimeout()
|
||||||
|
imageData := session.InspectImageJSON()
|
||||||
|
Expect(imageData[0].HealthCheck.Timeout).To(BeNumerically("==", 3000000000))
|
||||||
|
Expect(imageData[0].HealthCheck.Interval).To(BeNumerically("==", 60000000000))
|
||||||
|
Expect(imageData[0].HealthCheck.Test).To(Equal([]string{"CMD-SHELL", "curl -f http://localhost/ || exit 1"}))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user