Signed-off-by: Stephen J Day <stephen.day@docker.com>
| ... | ... |
@@ -387,7 +387,7 @@ func workdir(req dispatchRequest) error {
|
| 387 | 387 |
runConfig := req.state.runConfig |
| 388 | 388 |
// This is from the Dockerfile and will not necessarily be in platform |
| 389 | 389 |
// specific semantics, hence ensure it is converted. |
| 390 |
- runConfig.WorkingDir, err = normaliseWorkdir(req.builder.platform, runConfig.WorkingDir, req.args[0]) |
|
| 390 |
+ runConfig.WorkingDir, err = normalizeWorkdir(req.builder.platform, runConfig.WorkingDir, req.args[0]) |
|
| 391 | 391 |
if err != nil {
|
| 392 | 392 |
return err |
| 393 | 393 |
} |
| ... | ... |
@@ -9,11 +9,11 @@ import ( |
| 9 | 9 |
"path/filepath" |
| 10 | 10 |
) |
| 11 | 11 |
|
| 12 |
-// normaliseWorkdir normalises a user requested working directory in a |
|
| 12 |
+// normalizeWorkdir normalizes a user requested working directory in a |
|
| 13 | 13 |
// platform semantically consistent way. |
| 14 |
-func normaliseWorkdir(_ string, current string, requested string) (string, error) {
|
|
| 14 |
+func normalizeWorkdir(_ string, current string, requested string) (string, error) {
|
|
| 15 | 15 |
if requested == "" {
|
| 16 |
- return "", errors.New("cannot normalise nothing")
|
|
| 16 |
+ return "", errors.New("cannot normalize nothing")
|
|
| 17 | 17 |
} |
| 18 | 18 |
current = filepath.FromSlash(current) |
| 19 | 19 |
requested = filepath.FromSlash(requested) |
| ... | ... |
@@ -7,9 +7,9 @@ import ( |
| 7 | 7 |
"testing" |
| 8 | 8 |
) |
| 9 | 9 |
|
| 10 |
-func TestNormaliseWorkdir(t *testing.T) {
|
|
| 10 |
+func TestNormalizeWorkdir(t *testing.T) {
|
|
| 11 | 11 |
testCases := []struct{ current, requested, expected, expectedError string }{
|
| 12 |
- {``, ``, ``, `cannot normalise nothing`},
|
|
| 12 |
+ {``, ``, ``, `cannot normalize nothing`},
|
|
| 13 | 13 |
{``, `foo`, `/foo`, ``},
|
| 14 | 14 |
{``, `/foo`, `/foo`, ``},
|
| 15 | 15 |
{`/foo`, `bar`, `/foo/bar`, ``},
|
| ... | ... |
@@ -17,18 +17,18 @@ func TestNormaliseWorkdir(t *testing.T) {
|
| 17 | 17 |
} |
| 18 | 18 |
|
| 19 | 19 |
for _, test := range testCases {
|
| 20 |
- normalised, err := normaliseWorkdir(runtime.GOOS, test.current, test.requested) |
|
| 20 |
+ normalized, err := normalizeWorkdir(runtime.GOOS, test.current, test.requested) |
|
| 21 | 21 |
|
| 22 | 22 |
if test.expectedError != "" && err == nil {
|
| 23 |
- t.Fatalf("NormaliseWorkdir should return an error %s, got nil", test.expectedError)
|
|
| 23 |
+ t.Fatalf("NormalizeWorkdir should return an error %s, got nil", test.expectedError)
|
|
| 24 | 24 |
} |
| 25 | 25 |
|
| 26 | 26 |
if test.expectedError != "" && err.Error() != test.expectedError {
|
| 27 |
- t.Fatalf("NormaliseWorkdir returned wrong error. Expected %s, got %s", test.expectedError, err.Error())
|
|
| 27 |
+ t.Fatalf("NormalizeWorkdir returned wrong error. Expected %s, got %s", test.expectedError, err.Error())
|
|
| 28 | 28 |
} |
| 29 | 29 |
|
| 30 |
- if normalised != test.expected {
|
|
| 31 |
- t.Fatalf("NormaliseWorkdir error. Expected %s for current %s and requested %s, got %s", test.expected, test.current, test.requested, normalised)
|
|
| 30 |
+ if normalized != test.expected {
|
|
| 31 |
+ t.Fatalf("NormalizeWorkdir error. Expected %s for current %s and requested %s, got %s", test.expected, test.current, test.requested, normalized)
|
|
| 32 | 32 |
} |
| 33 | 33 |
} |
| 34 | 34 |
} |
| ... | ... |
@@ -14,23 +14,23 @@ import ( |
| 14 | 14 |
|
| 15 | 15 |
var pattern = regexp.MustCompile(`^[a-zA-Z]:\.$`) |
| 16 | 16 |
|
| 17 |
-// normaliseWorkdir normalises a user requested working directory in a |
|
| 17 |
+// normalizeWorkdir normalizes a user requested working directory in a |
|
| 18 | 18 |
// platform semantically consistent way. |
| 19 |
-func normaliseWorkdir(platform string, current string, requested string) (string, error) {
|
|
| 19 |
+func normalizeWorkdir(platform string, current string, requested string) (string, error) {
|
|
| 20 | 20 |
if platform == "" {
|
| 21 | 21 |
platform = "windows" |
| 22 | 22 |
} |
| 23 | 23 |
if platform == "windows" {
|
| 24 |
- return normaliseWorkdirWindows(current, requested) |
|
| 24 |
+ return normalizeWorkdirWindows(current, requested) |
|
| 25 | 25 |
} |
| 26 |
- return normaliseWorkdirUnix(current, requested) |
|
| 26 |
+ return normalizeWorkdirUnix(current, requested) |
|
| 27 | 27 |
} |
| 28 | 28 |
|
| 29 |
-// normaliseWorkdirUnix normalises a user requested working directory in a |
|
| 29 |
+// normalizeWorkdirUnix normalizes a user requested working directory in a |
|
| 30 | 30 |
// platform semantically consistent way. |
| 31 |
-func normaliseWorkdirUnix(current string, requested string) (string, error) {
|
|
| 31 |
+func normalizeWorkdirUnix(current string, requested string) (string, error) {
|
|
| 32 | 32 |
if requested == "" {
|
| 33 |
- return "", errors.New("cannot normalise nothing")
|
|
| 33 |
+ return "", errors.New("cannot normalize nothing")
|
|
| 34 | 34 |
} |
| 35 | 35 |
current = strings.Replace(current, string(os.PathSeparator), "/", -1) |
| 36 | 36 |
requested = strings.Replace(requested, string(os.PathSeparator), "/", -1) |
| ... | ... |
@@ -40,11 +40,11 @@ func normaliseWorkdirUnix(current string, requested string) (string, error) {
|
| 40 | 40 |
return requested, nil |
| 41 | 41 |
} |
| 42 | 42 |
|
| 43 |
-// normaliseWorkdirWindows normalises a user requested working directory in a |
|
| 43 |
+// normalizeWorkdirWindows normalizes a user requested working directory in a |
|
| 44 | 44 |
// platform semantically consistent way. |
| 45 |
-func normaliseWorkdirWindows(current string, requested string) (string, error) {
|
|
| 45 |
+func normalizeWorkdirWindows(current string, requested string) (string, error) {
|
|
| 46 | 46 |
if requested == "" {
|
| 47 |
- return "", errors.New("cannot normalise nothing")
|
|
| 47 |
+ return "", errors.New("cannot normalize nothing")
|
|
| 48 | 48 |
} |
| 49 | 49 |
|
| 50 | 50 |
// `filepath.Clean` will replace "" with "." so skip in that case |
| ... | ... |
@@ -4,9 +4,9 @@ package dockerfile |
| 4 | 4 |
|
| 5 | 5 |
import "testing" |
| 6 | 6 |
|
| 7 |
-func TestNormaliseWorkdir(t *testing.T) {
|
|
| 7 |
+func TestNormalizeWorkdir(t *testing.T) {
|
|
| 8 | 8 |
tests := []struct{ platform, current, requested, expected, etext string }{
|
| 9 |
- {"windows", ``, ``, ``, `cannot normalise nothing`},
|
|
| 9 |
+ {"windows", ``, ``, ``, `cannot normalize nothing`},
|
|
| 10 | 10 |
{"windows", ``, `C:`, ``, `C:. is not a directory. If you are specifying a drive letter, please add a trailing '\'`},
|
| 11 | 11 |
{"windows", ``, `C:.`, ``, `C:. is not a directory. If you are specifying a drive letter, please add a trailing '\'`},
|
| 12 | 12 |
{"windows", `c:`, `\a`, ``, `c:. is not a directory. If you are specifying a drive letter, please add a trailing '\'`},
|
| ... | ... |
@@ -21,7 +21,7 @@ func TestNormaliseWorkdir(t *testing.T) {
|
| 21 | 21 |
{"windows", `C:\foo`, `bar`, `C:\foo\bar`, ``},
|
| 22 | 22 |
{"windows", `C:\foo`, `/bar`, `C:\bar`, ``},
|
| 23 | 23 |
{"windows", `C:\foo`, `\bar`, `C:\bar`, ``},
|
| 24 |
- {"linux", ``, ``, ``, `cannot normalise nothing`},
|
|
| 24 |
+ {"linux", ``, ``, ``, `cannot normalize nothing`},
|
|
| 25 | 25 |
{"linux", ``, `foo`, `/foo`, ``},
|
| 26 | 26 |
{"linux", ``, `/foo`, `/foo`, ``},
|
| 27 | 27 |
{"linux", `/foo`, `bar`, `/foo/bar`, ``},
|
| ... | ... |
@@ -29,18 +29,18 @@ func TestNormaliseWorkdir(t *testing.T) {
|
| 29 | 29 |
{"linux", `\a`, `b\c`, `/a/b/c`, ``},
|
| 30 | 30 |
} |
| 31 | 31 |
for _, i := range tests {
|
| 32 |
- r, e := normaliseWorkdir(i.platform, i.current, i.requested) |
|
| 32 |
+ r, e := normalizeWorkdir(i.platform, i.current, i.requested) |
|
| 33 | 33 |
|
| 34 | 34 |
if i.etext != "" && e == nil {
|
| 35 |
- t.Fatalf("TestNormaliseWorkingDir Expected error %s for '%s' '%s', got no error", i.etext, i.current, i.requested)
|
|
| 35 |
+ t.Fatalf("TestNormalizeWorkingDir Expected error %s for '%s' '%s', got no error", i.etext, i.current, i.requested)
|
|
| 36 | 36 |
} |
| 37 | 37 |
|
| 38 | 38 |
if i.etext != "" && e.Error() != i.etext {
|
| 39 |
- t.Fatalf("TestNormaliseWorkingDir Expected error %s for '%s' '%s', got %s", i.etext, i.current, i.requested, e.Error())
|
|
| 39 |
+ t.Fatalf("TestNormalizeWorkingDir Expected error %s for '%s' '%s', got %s", i.etext, i.current, i.requested, e.Error())
|
|
| 40 | 40 |
} |
| 41 | 41 |
|
| 42 | 42 |
if r != i.expected {
|
| 43 |
- t.Fatalf("TestNormaliseWorkingDir Expected '%s' for '%s' '%s', got '%s'", i.expected, i.current, i.requested, r)
|
|
| 43 |
+ t.Fatalf("TestNormalizeWorkingDir Expected '%s' for '%s' '%s', got '%s'", i.expected, i.current, i.requested, r)
|
|
| 44 | 44 |
} |
| 45 | 45 |
} |
| 46 | 46 |
} |
| ... | ... |
@@ -140,7 +140,7 @@ func (b *Builder) performCopy(state *dispatchState, inst copyInstruction) error |
| 140 | 140 |
func createDestInfo(workingDir string, inst copyInstruction, imageMount *imageMount) (copyInfo, error) {
|
| 141 | 141 |
// Twiddle the destination when it's a relative path - meaning, make it |
| 142 | 142 |
// relative to the WORKINGDIR |
| 143 |
- dest, err := normaliseDest(workingDir, inst.dest) |
|
| 143 |
+ dest, err := normalizeDest(workingDir, inst.dest) |
|
| 144 | 144 |
if err != nil {
|
| 145 | 145 |
return copyInfo{}, errors.Wrapf(err, "invalid %s", inst.cmdName)
|
| 146 | 146 |
} |
| ... | ... |
@@ -10,9 +10,9 @@ import ( |
| 10 | 10 |
"github.com/docker/docker/pkg/system" |
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 |
-// normaliseDest normalises the destination of a COPY/ADD command in a |
|
| 13 |
+// normalizeDest normalizes the destination of a COPY/ADD command in a |
|
| 14 | 14 |
// platform semantically consistent way. |
| 15 |
-func normaliseDest(workingDir, requested string) (string, error) {
|
|
| 15 |
+func normalizeDest(workingDir, requested string) (string, error) {
|
|
| 16 | 16 |
dest := filepath.FromSlash(requested) |
| 17 | 17 |
endsInSlash := strings.HasSuffix(requested, string(os.PathSeparator)) |
| 18 | 18 |
if !system.IsAbs(requested) {
|
| ... | ... |
@@ -10,9 +10,9 @@ import ( |
| 10 | 10 |
"github.com/pkg/errors" |
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 |
-// normaliseDest normalises the destination of a COPY/ADD command in a |
|
| 13 |
+// normalizeDest normalizes the destination of a COPY/ADD command in a |
|
| 14 | 14 |
// platform semantically consistent way. |
| 15 |
-func normaliseDest(workingDir, requested string) (string, error) {
|
|
| 15 |
+func normalizeDest(workingDir, requested string) (string, error) {
|
|
| 16 | 16 |
dest := filepath.FromSlash(requested) |
| 17 | 17 |
endsInSlash := strings.HasSuffix(dest, string(os.PathSeparator)) |
| 18 | 18 |
|
| ... | ... |
@@ -10,7 +10,7 @@ import ( |
| 10 | 10 |
"github.com/stretchr/testify/assert" |
| 11 | 11 |
) |
| 12 | 12 |
|
| 13 |
-func TestNormaliseDest(t *testing.T) {
|
|
| 13 |
+func TestNormalizeDest(t *testing.T) {
|
|
| 14 | 14 |
tests := []struct{ current, requested, expected, etext string }{
|
| 15 | 15 |
{``, `D:\`, ``, `Windows does not support destinations not on the system drive (C:)`},
|
| 16 | 16 |
{``, `e:/`, ``, `Windows does not support destinations not on the system drive (C:)`},
|
| ... | ... |
@@ -40,7 +40,7 @@ func TestNormaliseDest(t *testing.T) {
|
| 40 | 40 |
} |
| 41 | 41 |
for _, testcase := range tests {
|
| 42 | 42 |
msg := fmt.Sprintf("Input: %s, %s", testcase.current, testcase.requested)
|
| 43 |
- actual, err := normaliseDest(testcase.current, testcase.requested) |
|
| 43 |
+ actual, err := normalizeDest(testcase.current, testcase.requested) |
|
| 44 | 44 |
if testcase.etext == "" {
|
| 45 | 45 |
if !assert.NoError(t, err, msg) {
|
| 46 | 46 |
continue |
| ... | ... |
@@ -122,7 +122,7 @@ func (s *DockerSuite) TestCommitChange(c *check.C) {
|
| 122 | 122 |
imageID = strings.TrimSpace(imageID) |
| 123 | 123 |
|
| 124 | 124 |
prefix, slash := getPrefixAndSlashFromDaemonPlatform() |
| 125 |
- prefix = strings.ToUpper(prefix) // Force C: as that's how WORKDIR is normalised on Windows |
|
| 125 |
+ prefix = strings.ToUpper(prefix) // Force C: as that's how WORKDIR is normalized on Windows |
|
| 126 | 126 |
expected := map[string]string{
|
| 127 | 127 |
"Config.ExposedPorts": "map[8080/tcp:{}]",
|
| 128 | 128 |
"Config.Env": "[DEBUG=true test=1 PATH=/foo]", |
| ... | ... |
@@ -188,7 +188,7 @@ func (s *VolumeStore) List() ([]volume.Volume, []string, error) {
|
| 188 | 188 |
var out []volume.Volume |
| 189 | 189 |
|
| 190 | 190 |
for _, v := range vols {
|
| 191 |
- name := normaliseVolumeName(v.Name()) |
|
| 191 |
+ name := normalizeVolumeName(v.Name()) |
|
| 192 | 192 |
|
| 193 | 193 |
s.locks.Lock(name) |
| 194 | 194 |
storedV, exists := s.getNamed(name) |
| ... | ... |
@@ -269,7 +269,7 @@ func (s *VolumeStore) list() ([]volume.Volume, []string, error) {
|
| 269 | 269 |
// CreateWithRef creates a volume with the given name and driver and stores the ref |
| 270 | 270 |
// This ensures there's no race between creating a volume and then storing a reference. |
| 271 | 271 |
func (s *VolumeStore) CreateWithRef(name, driverName, ref string, opts, labels map[string]string) (volume.Volume, error) {
|
| 272 |
- name = normaliseVolumeName(name) |
|
| 272 |
+ name = normalizeVolumeName(name) |
|
| 273 | 273 |
s.locks.Lock(name) |
| 274 | 274 |
defer s.locks.Unlock(name) |
| 275 | 275 |
|
| ... | ... |
@@ -432,7 +432,7 @@ func (s *VolumeStore) create(name, driverName string, opts, labels map[string]st |
| 432 | 432 |
// This is just like Get(), but we store the reference while holding the lock. |
| 433 | 433 |
// This makes sure there are no races between checking for the existence of a volume and adding a reference for it |
| 434 | 434 |
func (s *VolumeStore) GetWithRef(name, driverName, ref string) (volume.Volume, error) {
|
| 435 |
- name = normaliseVolumeName(name) |
|
| 435 |
+ name = normalizeVolumeName(name) |
|
| 436 | 436 |
s.locks.Lock(name) |
| 437 | 437 |
defer s.locks.Unlock(name) |
| 438 | 438 |
|
| ... | ... |
@@ -455,7 +455,7 @@ func (s *VolumeStore) GetWithRef(name, driverName, ref string) (volume.Volume, e |
| 455 | 455 |
|
| 456 | 456 |
// Get looks if a volume with the given name exists and returns it if so |
| 457 | 457 |
func (s *VolumeStore) Get(name string) (volume.Volume, error) {
|
| 458 |
- name = normaliseVolumeName(name) |
|
| 458 |
+ name = normalizeVolumeName(name) |
|
| 459 | 459 |
s.locks.Lock(name) |
| 460 | 460 |
defer s.locks.Unlock(name) |
| 461 | 461 |
|
| ... | ... |
@@ -558,7 +558,7 @@ func lookupVolume(driverName, volumeName string) (volume.Volume, error) {
|
| 558 | 558 |
|
| 559 | 559 |
// Remove removes the requested volume. A volume is not removed if it has any refs |
| 560 | 560 |
func (s *VolumeStore) Remove(v volume.Volume) error {
|
| 561 |
- name := normaliseVolumeName(v.Name()) |
|
| 561 |
+ name := normalizeVolumeName(v.Name()) |
|
| 562 | 562 |
s.locks.Lock(name) |
| 563 | 563 |
defer s.locks.Unlock(name) |
| 564 | 564 |
|
| ... | ... |
@@ -2,8 +2,8 @@ |
| 2 | 2 |
|
| 3 | 3 |
package store |
| 4 | 4 |
|
| 5 |
-// normaliseVolumeName is a platform specific function to normalise the name |
|
| 5 |
+// normalizeVolumeName is a platform specific function to normalize the name |
|
| 6 | 6 |
// of a volume. This is a no-op on Unix-like platforms |
| 7 |
-func normaliseVolumeName(name string) string {
|
|
| 7 |
+func normalizeVolumeName(name string) string {
|
|
| 8 | 8 |
return name |
| 9 | 9 |
} |
| ... | ... |
@@ -2,11 +2,11 @@ package store |
| 2 | 2 |
|
| 3 | 3 |
import "strings" |
| 4 | 4 |
|
| 5 |
-// normaliseVolumeName is a platform specific function to normalise the name |
|
| 5 |
+// normalizeVolumeName is a platform specific function to normalize the name |
|
| 6 | 6 |
// of a volume. On Windows, as NTFS is case insensitive, under |
| 7 | 7 |
// c:\ProgramData\Docker\Volumes\, the folders John and john would be synonymous. |
| 8 | 8 |
// Hence we can't allow the volume "John" and "john" to be created as separate |
| 9 | 9 |
// volumes. |
| 10 |
-func normaliseVolumeName(name string) string {
|
|
| 10 |
+func normalizeVolumeName(name string) string {
|
|
| 11 | 11 |
return strings.ToLower(name) |
| 12 | 12 |
} |