mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Refactor MountPoint Setup function in volume.go
Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com>
This commit is contained in:
parent
e066edcfcf
commit
fb8b27cd41
1 changed files with 11 additions and 13 deletions
|
@ -153,20 +153,18 @@ func (m *MountPoint) Cleanup() error {
|
||||||
// before creating the source directory on the host.
|
// before creating the source directory on the host.
|
||||||
func (m *MountPoint) Setup(mountLabel string, rootIDs idtools.IDPair, checkFun func(m *MountPoint) error) (path string, err error) {
|
func (m *MountPoint) Setup(mountLabel string, rootIDs idtools.IDPair, checkFun func(m *MountPoint) error) (path string, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err == nil {
|
if err != nil || !label.RelabelNeeded(m.Mode) {
|
||||||
if label.RelabelNeeded(m.Mode) {
|
return
|
||||||
if err = label.Relabel(m.Source, mountLabel, label.IsShared(m.Mode)); err != nil {
|
}
|
||||||
|
|
||||||
|
err = label.Relabel(m.Source, mountLabel, label.IsShared(m.Mode))
|
||||||
if err == syscall.ENOTSUP {
|
if err == syscall.ENOTSUP {
|
||||||
err = nil
|
err = nil
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
if err != nil {
|
||||||
path = ""
|
path = ""
|
||||||
err = errors.Wrapf(err, "error setting label on mount source '%s'", m.Source)
|
err = errors.Wrapf(err, "error setting label on mount source '%s'", m.Source)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if m.Volume != nil {
|
if m.Volume != nil {
|
||||||
|
|
Loading…
Reference in a new issue