summaryrefslogtreecommitdiff
path: root/pkg/domain
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-01-21 15:31:32 -0500
committerGitHub <noreply@github.com>2021-01-21 15:31:32 -0500
commit6fd83de31dab0c60932972c6b26f68fa0bd1871f (patch)
treed017ed4d59da4a0f0b703430d60b2d2f43484aaa /pkg/domain
parent3ba1a8de8649db2f5cdde80d0f4cf02370e10b8a (diff)
parent9d31fed5f75186f618e95ab7492ef6bc2b511d5f (diff)
downloadpodman-6fd83de31dab0c60932972c6b26f68fa0bd1871f.tar.gz
podman-6fd83de31dab0c60932972c6b26f68fa0bd1871f.tar.bz2
podman-6fd83de31dab0c60932972c6b26f68fa0bd1871f.zip
Merge pull request #9027 from Luap99/podman-volume-exists
Podman volume exists
Diffstat (limited to 'pkg/domain')
-rw-r--r--pkg/domain/entities/engine_container.go1
-rw-r--r--pkg/domain/infra/abi/volumes.go9
-rw-r--r--pkg/domain/infra/tunnel/volumes.go11
3 files changed, 21 insertions, 0 deletions
diff --git a/pkg/domain/entities/engine_container.go b/pkg/domain/entities/engine_container.go
index 7b43ac961..39bda1d72 100644
--- a/pkg/domain/entities/engine_container.go
+++ b/pkg/domain/entities/engine_container.go
@@ -86,6 +86,7 @@ type ContainerEngine interface {
Unshare(ctx context.Context, args []string) error
Version(ctx context.Context) (*SystemVersionReport, error)
VolumeCreate(ctx context.Context, opts VolumeCreateOptions) (*IDOrNameResponse, error)
+ VolumeExists(ctx context.Context, namesOrId string) (*BoolReport, error)
VolumeInspect(ctx context.Context, namesOrIds []string, opts InspectOptions) ([]*VolumeInspectReport, []error, error)
VolumeList(ctx context.Context, opts VolumeListOptions) ([]*VolumeListReport, error)
VolumePrune(ctx context.Context, options VolumePruneOptions) ([]*reports.PruneReport, error)
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
+}