Forráskód Böngészése

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 c32dde5baadc8c472666ef9d5cead13ab6de28ea. 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>
Sebastiaan van Stijn 2 éve
szülő
commit
c78af57e21
2 módosított fájl, 3 hozzáadás és 7 törlés
  1. 3 1
      daemon/archive_unix.go
  2. 0 6
      daemon/volumes.go

+ 3 - 1
daemon/archive_unix.go

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

+ 0 - 6
daemon/volumes.go

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