diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-03-06 09:24:22 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-06 09:24:22 -0800 |
commit | c6c0b54c361df623378706ca5e41faac309ab7ac (patch) | |
tree | 3694ec6a3953469c7db115e2e00fb7e2a1ced003 /libpod/image/image.go | |
parent | 2b5a9628324c4d93769d72d3d8c85667eaac612a (diff) | |
parent | 598bde52d02eb82634c6b1fa357253f03120a4a0 (diff) | |
download | podman-c6c0b54c361df623378706ca5e41faac309ab7ac.tar.gz podman-c6c0b54c361df623378706ca5e41faac309ab7ac.tar.bz2 podman-c6c0b54c361df623378706ca5e41faac309ab7ac.zip |
Merge pull request #2491 from baude/healtcheckphase1
podman healthcheck run (phase 1)
Diffstat (limited to 'libpod/image/image.go')
-rw-r--r-- | libpod/image/image.go | 29 |
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 +} |