summaryrefslogtreecommitdiff
path: root/libpod/image/image.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-04-18 05:57:18 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2020-04-20 15:50:46 -0400
commita2ad5bb9e1541707af39a19ec18997f6f0d77a0e (patch)
tree752bf4075f25e256bf0e33f1348e537498a3a2bf /libpod/image/image.go
parent5928e8fe80e1f013049f1a980a4c945ee35570c3 (diff)
downloadpodman-a2ad5bb9e1541707af39a19ec18997f6f0d77a0e.tar.gz
podman-a2ad5bb9e1541707af39a19ec18997f6f0d77a0e.tar.bz2
podman-a2ad5bb9e1541707af39a19ec18997f6f0d77a0e.zip
Add functions to return image informations
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'libpod/image/image.go')
-rw-r--r--libpod/image/image.go61
1 files changed, 58 insertions, 3 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go
index 7198a42a3..bbf803056 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -867,22 +867,77 @@ func (i *Image) Intermediate(ctx context.Context) (bool, error) {
return false, nil
}
+// User returns the image's user
+func (i *Image) User(ctx context.Context) (string, error) {
+ imgInspect, err := i.inspect(ctx, false)
+ if err != nil {
+ return "", err
+ }
+ return imgInspect.Config.User, nil
+}
+
+// StopSignal returns the image's StopSignal
+func (i *Image) StopSignal(ctx context.Context) (string, error) {
+ imgInspect, err := i.inspect(ctx, false)
+ if err != nil {
+ return "", err
+ }
+ return imgInspect.Config.StopSignal, nil
+}
+
+// WorkingDir returns the image's WorkingDir
+func (i *Image) WorkingDir(ctx context.Context) (string, error) {
+ imgInspect, err := i.inspect(ctx, false)
+ if err != nil {
+ return "", err
+ }
+ return imgInspect.Config.WorkingDir, nil
+}
+
+// Cmd returns the image's cmd
+func (i *Image) Cmd(ctx context.Context) ([]string, error) {
+ imgInspect, err := i.inspect(ctx, false)
+ if err != nil {
+ return nil, err
+ }
+ return imgInspect.Config.Cmd, nil
+}
+
+// Entrypoint returns the image's entrypoint
+func (i *Image) Entrypoint(ctx context.Context) ([]string, error) {
+ imgInspect, err := i.inspect(ctx, false)
+ if err != nil {
+ return nil, err
+ }
+ return imgInspect.Config.Entrypoint, nil
+}
+
+// Env returns the image's env
+func (i *Image) Env(ctx context.Context) ([]string, error) {
+ imgInspect, err := i.imageInspectInfo(ctx)
+ if err != nil {
+ return nil, err
+ }
+ return imgInspect.Env, nil
+}
+
// Labels returns the image's labels
func (i *Image) Labels(ctx context.Context) (map[string]string, error) {
imgInspect, err := i.imageInspectInfo(ctx)
if err != nil {
- return nil, nil
+ return nil, err
}
return imgInspect.Labels, nil
}
// GetLabel Returns a case-insensitive match of a given label
func (i *Image) GetLabel(ctx context.Context, label string) (string, error) {
- imageLabels, err := i.Labels(ctx)
+ labels, err := i.Labels(ctx)
if err != nil {
return "", err
}
- for k, v := range imageLabels {
+
+ for k, v := range labels {
if strings.ToLower(k) == strings.ToLower(label) {
return v, nil
}