From 36a4cc864d1de57cd822a81d01f0b5f1b40eaa7d Mon Sep 17 00:00:00 2001 From: Jhon Honce Date: Tue, 24 Mar 2020 17:53:28 -0700 Subject: V2 podman image * Exists() Signed-off-by: Jhon Honce --- pkg/domain/infra/abi/images.go | 7 +++++++ pkg/domain/infra/tunnel/images.go | 5 +++++ 2 files changed, 12 insertions(+) (limited to 'pkg/domain/infra') diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go index 6e9d7f566..39a03ef6c 100644 --- a/pkg/domain/infra/abi/images.go +++ b/pkg/domain/infra/abi/images.go @@ -10,6 +10,13 @@ import ( "github.com/containers/libpod/pkg/domain/utils" ) +func (ir *ImageEngine) Exists(_ context.Context, nameOrId string) (*entities.BoolReport, error) { + if _, err := ir.Libpod.ImageRuntime().NewFromLocal(nameOrId); err != nil { + return &entities.BoolReport{}, nil + } + return &entities.BoolReport{Value: true}, nil +} + func (ir *ImageEngine) Delete(ctx context.Context, nameOrId string, opts entities.ImageDeleteOptions) (*entities.ImageDeleteReport, error) { image, err := ir.Libpod.ImageRuntime().NewFromLocal(nameOrId) if err != nil { diff --git a/pkg/domain/infra/tunnel/images.go b/pkg/domain/infra/tunnel/images.go index 60df40498..921e4a6e3 100644 --- a/pkg/domain/infra/tunnel/images.go +++ b/pkg/domain/infra/tunnel/images.go @@ -9,6 +9,11 @@ import ( "github.com/containers/libpod/pkg/domain/utils" ) +func (ir *ImageEngine) Exists(_ context.Context, nameOrId string) (*entities.BoolReport, error) { + found, err := images.Exists(ir.ClientCxt, nameOrId) + return &entities.BoolReport{Value: found}, err +} + func (ir *ImageEngine) Delete(ctx context.Context, nameOrId string, opts entities.ImageDeleteOptions) (*entities.ImageDeleteReport, error) { results, err := images.Remove(ir.ClientCxt, nameOrId, &opts.Force) if err != nil { -- cgit v1.2.3-54-g00ecf