summaryrefslogtreecommitdiff
path: root/libpod/runtime_volume.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-07-24 10:57:40 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-07-24 22:30:16 -0400
commitf747a06d53b5d9d998bcfd55df482fc9e895654b (patch)
treeb1cc38fe85edd4d74fe02ce10bc5d46ab24348b6 /libpod/runtime_volume.go
parent2283471f8da7c3dc1a2cc6e1fe908c0fe7596d68 (diff)
downloadpodman-f747a06d53b5d9d998bcfd55df482fc9e895654b.tar.gz
podman-f747a06d53b5d9d998bcfd55df482fc9e895654b.tar.bz2
podman-f747a06d53b5d9d998bcfd55df482fc9e895654b.zip
When retrieving volumes, only use exact names
We should not be fuzzy matching on volume names. Docker doesn't do it, and it doesn't make much sense. Everything requires exact matches for names - only IDs allow partial matches. Fixes #3635 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/runtime_volume.go')
-rw-r--r--libpod/runtime_volume.go16
1 files changed, 3 insertions, 13 deletions
diff --git a/libpod/runtime_volume.go b/libpod/runtime_volume.go
index 5c087faca..d05db936b 100644
--- a/libpod/runtime_volume.go
+++ b/libpod/runtime_volume.go
@@ -2,7 +2,6 @@ package libpod
import (
"context"
- "strings"
"github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/libpod/events"
@@ -72,7 +71,7 @@ func (r *Runtime) RemoveVolumes(ctx context.Context, volumes []string, all, forc
return deletedVols, nil
}
-// GetVolume retrieves a volume by its name
+// GetVolume retrieves a volume given its full name.
func (r *Runtime) GetVolume(name string) (*Volume, error) {
r.lock.RLock()
defer r.lock.RUnlock()
@@ -82,20 +81,11 @@ func (r *Runtime) GetVolume(name string) (*Volume, error) {
}
vol, err := r.state.Volume(name)
- if err == nil {
- return vol, err
- }
-
- vols, err := r.GetAllVolumes()
if err != nil {
return nil, err
}
- for _, v := range vols {
- if strings.HasPrefix(v.Name(), name) {
- return v, nil
- }
- }
- return nil, errors.Errorf("unable to find volume %s", name)
+
+ return vol, nil
}
// HasVolume checks to see if a volume with the given name exists