Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Vincent Demeester authored on 2016/12/22 06:42:471 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,9 @@ |
0 |
+package api |
|
1 |
+ |
|
2 |
+import "regexp" |
|
3 |
+ |
|
4 |
+// RestrictedNameChars collects the characters allowed to represent a name, normally used to validate container and volume names. |
|
5 |
+const RestrictedNameChars = `[a-zA-Z0-9][a-zA-Z0-9_.-]` |
|
6 |
+ |
|
7 |
+// RestrictedNamePattern is a regular expression to validate names against the collection of restricted characters. |
|
8 |
+var RestrictedNamePattern = regexp.MustCompile(`^` + RestrictedNameChars + `+$`) |
... | ... |
@@ -7,13 +7,13 @@ import ( |
7 | 7 |
"os" |
8 | 8 |
"path/filepath" |
9 | 9 |
|
10 |
+ "github.com/docker/docker/api" |
|
10 | 11 |
"github.com/docker/docker/api/types" |
11 |
- "github.com/docker/docker/utils" |
|
12 | 12 |
) |
13 | 13 |
|
14 | 14 |
var ( |
15 |
- validCheckpointNameChars = utils.RestrictedNameChars |
|
16 |
- validCheckpointNamePattern = utils.RestrictedNamePattern |
|
15 |
+ validCheckpointNameChars = api.RestrictedNameChars |
|
16 |
+ validCheckpointNamePattern = api.RestrictedNamePattern |
|
17 | 17 |
) |
18 | 18 |
|
19 | 19 |
// CheckpointCreate checkpoints the process running in a container with CRIU |
... | ... |
@@ -5,16 +5,16 @@ import ( |
5 | 5 |
"strings" |
6 | 6 |
|
7 | 7 |
"github.com/Sirupsen/logrus" |
8 |
+ "github.com/docker/docker/api" |
|
8 | 9 |
"github.com/docker/docker/container" |
9 | 10 |
"github.com/docker/docker/pkg/namesgenerator" |
10 | 11 |
"github.com/docker/docker/pkg/registrar" |
11 | 12 |
"github.com/docker/docker/pkg/stringid" |
12 |
- "github.com/docker/docker/utils" |
|
13 | 13 |
) |
14 | 14 |
|
15 | 15 |
var ( |
16 |
- validContainerNameChars = utils.RestrictedNameChars |
|
17 |
- validContainerNamePattern = utils.RestrictedNamePattern |
|
16 |
+ validContainerNameChars = api.RestrictedNameChars |
|
17 |
+ validContainerNamePattern = api.RestrictedNamePattern |
|
18 | 18 |
) |
19 | 19 |
|
20 | 20 |
func (daemon *Daemon) registerName(container *container.Container) error { |
21 | 21 |
deleted file mode 100644 |
... | ... |
@@ -1,9 +0,0 @@ |
1 |
-package utils |
|
2 |
- |
|
3 |
-import "regexp" |
|
4 |
- |
|
5 |
-// RestrictedNameChars collects the characters allowed to represent a name, normally used to validate container and volume names. |
|
6 |
-const RestrictedNameChars = `[a-zA-Z0-9][a-zA-Z0-9_.-]` |
|
7 |
- |
|
8 |
-// RestrictedNamePattern is a regular expression to validate names against the collection of restricted characters. |
|
9 |
-var RestrictedNamePattern = regexp.MustCompile(`^` + RestrictedNameChars + `+$`) |
... | ... |
@@ -16,9 +16,9 @@ import ( |
16 | 16 |
"github.com/pkg/errors" |
17 | 17 |
|
18 | 18 |
"github.com/Sirupsen/logrus" |
19 |
+ "github.com/docker/docker/api" |
|
19 | 20 |
"github.com/docker/docker/pkg/idtools" |
20 | 21 |
"github.com/docker/docker/pkg/mount" |
21 |
- "github.com/docker/docker/utils" |
|
22 | 22 |
"github.com/docker/docker/volume" |
23 | 23 |
) |
24 | 24 |
|
... | ... |
@@ -36,7 +36,7 @@ var ( |
36 | 36 |
// volumeNameRegex ensures the name assigned for the volume is valid. |
37 | 37 |
// This name is used to create the bind directory, so we need to avoid characters that |
38 | 38 |
// would make the path to escape the root directory. |
39 |
- volumeNameRegex = utils.RestrictedNamePattern |
|
39 |
+ volumeNameRegex = api.RestrictedNamePattern |
|
40 | 40 |
) |
41 | 41 |
|
42 | 42 |
type validationError struct { |
... | ... |
@@ -269,7 +269,7 @@ func (r *Root) validateName(name string) error { |
269 | 269 |
return validationError{fmt.Errorf("volume name is too short, names should be at least two alphanumeric characters")} |
270 | 270 |
} |
271 | 271 |
if !volumeNameRegex.MatchString(name) { |
272 |
- return validationError{fmt.Errorf("%q includes invalid characters for a local volume name, only %q are allowed. If you intented to pass a host directory, use absolute path", name, utils.RestrictedNameChars)} |
|
272 |
+ return validationError{fmt.Errorf("%q includes invalid characters for a local volume name, only %q are allowed. If you intented to pass a host directory, use absolute path", name, api.RestrictedNameChars)} |
|
273 | 273 |
} |
274 | 274 |
return nil |
275 | 275 |
} |