فهرست منبع

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 c32dde5baadc8c472666ef9d5cead13ab6de28ea, 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>
Sebastiaan van Stijn 2 سال پیش
والد
کامیت
0f1eeed5c2
2فایلهای تغییر یافته به همراه1 افزوده شده و 5 حذف شده
  1. 1 1
      daemon/archive.go
  2. 0 4
      daemon/container_operations.go

+ 1 - 1
daemon/archive.go

@@ -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)

+ 0 - 4
daemon/container_operations.go

@@ -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