mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
daemon: replace ErrVolumeReadonly with errdefs
It was only used in a single location, and the ErrVolumeReadonly was not checked
for, or used as a sentinel error.
This error was introduced in c32dde5baa
. It was
never used as a sentinel error, but from that commit, it looks like it was added
as a package variable to mirror already existing errors defined at the package
level.
This patch removes the exported variable, and replaces the error with an
errdefs.InvalidParameter(), so that the API also returns the correct (400)
status code.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
0f1eeed5c2
commit
c78af57e21
2 changed files with 3 additions and 7 deletions
|
@ -5,7 +5,9 @@ package daemon // import "github.com/docker/docker/daemon"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/docker/docker/container"
|
"github.com/docker/docker/container"
|
||||||
|
"github.com/docker/docker/errdefs"
|
||||||
volumemounts "github.com/docker/docker/volume/mounts"
|
volumemounts "github.com/docker/docker/volume/mounts"
|
||||||
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
// checkIfPathIsInAVolume checks if the path is in a volume. If it is, it
|
// checkIfPathIsInAVolume checks if the path is in a volume. If it is, it
|
||||||
|
@ -19,7 +21,7 @@ func checkIfPathIsInAVolume(container *container.Container, absPath string) (boo
|
||||||
if mnt.RW {
|
if mnt.RW {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
return false, ErrVolumeReadonly
|
return false, errdefs.InvalidParameter(errors.New("mounted volume is marked read-only"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return toVolume, nil
|
return toVolume, nil
|
||||||
|
|
|
@ -21,12 +21,6 @@ import (
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
// ErrVolumeReadonly is used to signal an error when trying to copy data into
|
|
||||||
// a volume mount that is not writable.
|
|
||||||
ErrVolumeReadonly = errors.New("mounted volume is marked read-only")
|
|
||||||
)
|
|
||||||
|
|
||||||
type mounts []container.Mount
|
type mounts []container.Mount
|
||||||
|
|
||||||
// Len returns the number of mounts. Used in sorting.
|
// Len returns the number of mounts. Used in sorting.
|
||||||
|
|
Loading…
Add table
Reference in a new issue