daemon: replace ErrRootFSReadOnly with errdefs

It was only used in a single location, and the ErrRootFSReadOnly was not checked
for, or used as a sentinel error.

This error was introduced in c32dde5baa, originally
named `ErrContainerRootfsReadonly`. It was never used as a sentinel error, but
from that commit, it looks like it was added as a package variable to mirror
the coding style of 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-26 20:44:36 +02:00
parent e31e9180cd
commit 0f1eeed5c2
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 1 additions and 5 deletions

View File

@ -326,7 +326,7 @@ func (daemon *Daemon) containerExtractToDir(container *container.Container, path
}
if !toVolume && container.HostConfig.ReadonlyRootfs {
return ErrRootFSReadOnly
return errdefs.InvalidParameter(errors.New("container rootfs is marked read-only"))
}
options := daemon.defaultTarCopyOptions(noOverwriteDirNonDir)

View File

@ -26,10 +26,6 @@ import (
"github.com/sirupsen/logrus"
)
// ErrRootFSReadOnly is returned when a container
// rootfs is marked readonly.
var ErrRootFSReadOnly = errors.New("container rootfs is marked read-only")
func (daemon *Daemon) getDNSSearchSettings(container *container.Container) []string {
if len(container.HostConfig.DNSSearch) > 0 {
return container.HostConfig.DNSSearch