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:
Sebastiaan van Stijn 2022-09-27 22:17:27 +02:00
parent 0f1eeed5c2
commit c78af57e21
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 3 additions and 7 deletions

View File

@ -5,7 +5,9 @@ package daemon // import "github.com/docker/docker/daemon"
import (
"github.com/docker/docker/container"
"github.com/docker/docker/errdefs"
volumemounts "github.com/docker/docker/volume/mounts"
"github.com/pkg/errors"
)
// 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 {
break
}
return false, ErrVolumeReadonly
return false, errdefs.InvalidParameter(errors.New("mounted volume is marked read-only"))
}
}
return toVolume, nil

View File

@ -21,12 +21,6 @@ import (
"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
// Len returns the number of mounts. Used in sorting.