summaryrefslogtreecommitdiff
path: root/libpod/image/image.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-02-26 20:54:57 -0600
committerbaude <bbaude@redhat.com>2019-03-05 14:03:55 -0600
commit598bde52d02eb82634c6b1fa357253f03120a4a0 (patch)
tree08c935792c9e1d57ee00f8db98b3f1a74987f4b6 /libpod/image/image.go
parent645426fe797f90fc75712388e0373158f13bab0a (diff)
downloadpodman-598bde52d02eb82634c6b1fa357253f03120a4a0.tar.gz
podman-598bde52d02eb82634c6b1fa357253f03120a4a0.tar.bz2
podman-598bde52d02eb82634c6b1fa357253f03120a4a0.zip
podman healthcheck run (phase 1)
Add the ability to manually run a container's healthcheck command. This is only the first phase of implementing the healthcheck. Subsequent pull requests will deal with the exposing the results and history of healthchecks as well as the scheduling. Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'libpod/image/image.go')
-rw-r--r--libpod/image/image.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go
index b20419d7b..8c98de3d3 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -1151,3 +1151,32 @@ func (i *Image) Save(ctx context.Context, source, format, output string, moreTag
return nil
}
+
+// GetConfigBlob returns a schema2image. If the image is not a schema2, then
+// it will return an error
+func (i *Image) GetConfigBlob(ctx context.Context) (*manifest.Schema2Image, error) {
+ imageRef, err := i.toImageRef(ctx)
+ if err != nil {
+ return nil, err
+ }
+ b, err := imageRef.ConfigBlob(ctx)
+ if err != nil {
+ return nil, errors.Wrapf(err, "unable to get config blob for %s", i.ID())
+ }
+ blob := manifest.Schema2Image{}
+ if err := json.Unmarshal(b, &blob); err != nil {
+ return nil, errors.Wrapf(err, "unable to parse image blob for %s", i.ID())
+ }
+ return &blob, nil
+
+}
+
+// GetHealthCheck returns a HealthConfig for an image. This function only works with
+// schema2 images.
+func (i *Image) GetHealthCheck(ctx context.Context) (*manifest.Schema2HealthConfig, error) {
+ configBlob, err := i.GetConfigBlob(ctx)
+ if err != nil {
+ return nil, err
+ }
+ return configBlob.ContainerConfig.Healthcheck, nil
+}