Skip to content

Commit

Permalink
Merge pull request #3641 from mheon/no_fuzzy_volume_lookup
Browse files Browse the repository at this point in the history
When retrieving volumes, only use exact names
  • Loading branch information
openshift-merge-robot authored Jul 25, 2019
2 parents 2283471 + f747a06 commit 7c9095e
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions libpod/runtime_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package libpod

import (
"context"
"strings"

"github.com/containers/libpod/libpod/define"
"github.com/containers/libpod/libpod/events"
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit 7c9095e

Please sign in to comment.