summaryrefslogtreecommitdiff
path: root/pkg/domain/infra
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/domain/infra')
-rw-r--r--pkg/domain/infra/abi/volumes.go9
-rw-r--r--pkg/domain/infra/tunnel/volumes.go11
2 files changed, 20 insertions, 0 deletions
diff --git a/pkg/domain/infra/abi/volumes.go b/pkg/domain/infra/abi/volumes.go
index 823605052..f15aa2d14 100644
--- a/pkg/domain/infra/abi/volumes.go
+++ b/pkg/domain/infra/abi/volumes.go
@@ -153,3 +153,12 @@ func (ic *ContainerEngine) VolumeList(ctx context.Context, opts entities.VolumeL
}
return reports, nil
}
+
+// VolumeExists check if a given volume name exists
+func (ic *ContainerEngine) VolumeExists(ctx context.Context, nameOrID string) (*entities.BoolReport, error) {
+ exists, err := ic.Libpod.HasVolume(nameOrID)
+ if err != nil {
+ return nil, err
+ }
+ return &entities.BoolReport{Value: exists}, nil
+}
diff --git a/pkg/domain/infra/tunnel/volumes.go b/pkg/domain/infra/tunnel/volumes.go
index f21336828..ffd2c1d35 100644
--- a/pkg/domain/infra/tunnel/volumes.go
+++ b/pkg/domain/infra/tunnel/volumes.go
@@ -80,3 +80,14 @@ func (ic *ContainerEngine) VolumeList(ctx context.Context, opts entities.VolumeL
options := new(volumes.ListOptions).WithFilters(opts.Filter)
return volumes.List(ic.ClientCtx, options)
}
+
+// VolumeExists checks if the given volume exists
+func (ic *ContainerEngine) VolumeExists(ctx context.Context, nameOrID string) (*entities.BoolReport, error) {
+ exists, err := volumes.Exists(ic.ClientCtx, nameOrID, nil)
+ if err != nil {
+ return nil, err
+ }
+ return &entities.BoolReport{
+ Value: exists,
+ }, nil
+}