浏览代码

*: normalize the use of normalize

Signed-off-by: Stephen J Day <stephen.day@docker.com>
Stephen J Day 7 年之前
父节点
当前提交
ae8dbeaeed

+ 1 - 1
builder/dockerfile/dispatchers.go

@@ -387,7 +387,7 @@ func workdir(req dispatchRequest) error {
 	runConfig := req.state.runConfig
 	// This is from the Dockerfile and will not necessarily be in platform
 	// specific semantics, hence ensure it is converted.
-	runConfig.WorkingDir, err = normaliseWorkdir(req.builder.platform, runConfig.WorkingDir, req.args[0])
+	runConfig.WorkingDir, err = normalizeWorkdir(req.builder.platform, runConfig.WorkingDir, req.args[0])
 	if err != nil {
 		return err
 	}

+ 3 - 3
builder/dockerfile/dispatchers_unix.go

@@ -9,11 +9,11 @@ import (
 	"path/filepath"
 )
 
-// normaliseWorkdir normalises a user requested working directory in a
+// normalizeWorkdir normalizes a user requested working directory in a
 // platform semantically consistent way.
-func normaliseWorkdir(_ string, current string, requested string) (string, error) {
+func normalizeWorkdir(_ string, current string, requested string) (string, error) {
 	if requested == "" {
-		return "", errors.New("cannot normalise nothing")
+		return "", errors.New("cannot normalize nothing")
 	}
 	current = filepath.FromSlash(current)
 	requested = filepath.FromSlash(requested)

+ 7 - 7
builder/dockerfile/dispatchers_unix_test.go

@@ -7,9 +7,9 @@ import (
 	"testing"
 )
 
-func TestNormaliseWorkdir(t *testing.T) {
+func TestNormalizeWorkdir(t *testing.T) {
 	testCases := []struct{ current, requested, expected, expectedError string }{
-		{``, ``, ``, `cannot normalise nothing`},
+		{``, ``, ``, `cannot normalize nothing`},
 		{``, `foo`, `/foo`, ``},
 		{``, `/foo`, `/foo`, ``},
 		{`/foo`, `bar`, `/foo/bar`, ``},
@@ -17,18 +17,18 @@ func TestNormaliseWorkdir(t *testing.T) {
 	}
 
 	for _, test := range testCases {
-		normalised, err := normaliseWorkdir(runtime.GOOS, test.current, test.requested)
+		normalized, err := normalizeWorkdir(runtime.GOOS, test.current, test.requested)
 
 		if test.expectedError != "" && err == nil {
-			t.Fatalf("NormaliseWorkdir should return an error %s, got nil", test.expectedError)
+			t.Fatalf("NormalizeWorkdir should return an error %s, got nil", test.expectedError)
 		}
 
 		if test.expectedError != "" && err.Error() != test.expectedError {
-			t.Fatalf("NormaliseWorkdir returned wrong error. Expected %s, got %s", test.expectedError, err.Error())
+			t.Fatalf("NormalizeWorkdir returned wrong error. Expected %s, got %s", test.expectedError, err.Error())
 		}
 
-		if normalised != test.expected {
-			t.Fatalf("NormaliseWorkdir error. Expected %s for current %s and requested %s, got %s", test.expected, test.current, test.requested, normalised)
+		if normalized != test.expected {
+			t.Fatalf("NormalizeWorkdir error. Expected %s for current %s and requested %s, got %s", test.expected, test.current, test.requested, normalized)
 		}
 	}
 }

+ 10 - 10
builder/dockerfile/dispatchers_windows.go

@@ -14,23 +14,23 @@ import (
 
 var pattern = regexp.MustCompile(`^[a-zA-Z]:\.$`)
 
-// normaliseWorkdir normalises a user requested working directory in a
+// normalizeWorkdir normalizes a user requested working directory in a
 // platform semantically consistent way.
-func normaliseWorkdir(platform string, current string, requested string) (string, error) {
+func normalizeWorkdir(platform string, current string, requested string) (string, error) {
 	if platform == "" {
 		platform = "windows"
 	}
 	if platform == "windows" {
-		return normaliseWorkdirWindows(current, requested)
+		return normalizeWorkdirWindows(current, requested)
 	}
-	return normaliseWorkdirUnix(current, requested)
+	return normalizeWorkdirUnix(current, requested)
 }
 
-// normaliseWorkdirUnix normalises a user requested working directory in a
+// normalizeWorkdirUnix normalizes a user requested working directory in a
 // platform semantically consistent way.
-func normaliseWorkdirUnix(current string, requested string) (string, error) {
+func normalizeWorkdirUnix(current string, requested string) (string, error) {
 	if requested == "" {
-		return "", errors.New("cannot normalise nothing")
+		return "", errors.New("cannot normalize nothing")
 	}
 	current = strings.Replace(current, string(os.PathSeparator), "/", -1)
 	requested = strings.Replace(requested, string(os.PathSeparator), "/", -1)
@@ -40,11 +40,11 @@ func normaliseWorkdirUnix(current string, requested string) (string, error) {
 	return requested, nil
 }
 
-// normaliseWorkdirWindows normalises a user requested working directory in a
+// normalizeWorkdirWindows normalizes a user requested working directory in a
 // platform semantically consistent way.
-func normaliseWorkdirWindows(current string, requested string) (string, error) {
+func normalizeWorkdirWindows(current string, requested string) (string, error) {
 	if requested == "" {
-		return "", errors.New("cannot normalise nothing")
+		return "", errors.New("cannot normalize nothing")
 	}
 
 	// `filepath.Clean` will replace "" with "." so skip in that case

+ 7 - 7
builder/dockerfile/dispatchers_windows_test.go

@@ -4,9 +4,9 @@ package dockerfile
 
 import "testing"
 
-func TestNormaliseWorkdir(t *testing.T) {
+func TestNormalizeWorkdir(t *testing.T) {
 	tests := []struct{ platform, current, requested, expected, etext string }{
-		{"windows", ``, ``, ``, `cannot normalise nothing`},
+		{"windows", ``, ``, ``, `cannot normalize nothing`},
 		{"windows", ``, `C:`, ``, `C:. is not a directory. If you are specifying a drive letter, please add a trailing '\'`},
 		{"windows", ``, `C:.`, ``, `C:. is not a directory. If you are specifying a drive letter, please add a trailing '\'`},
 		{"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) {
 		{"windows", `C:\foo`, `bar`, `C:\foo\bar`, ``},
 		{"windows", `C:\foo`, `/bar`, `C:\bar`, ``},
 		{"windows", `C:\foo`, `\bar`, `C:\bar`, ``},
-		{"linux", ``, ``, ``, `cannot normalise nothing`},
+		{"linux", ``, ``, ``, `cannot normalize nothing`},
 		{"linux", ``, `foo`, `/foo`, ``},
 		{"linux", ``, `/foo`, `/foo`, ``},
 		{"linux", `/foo`, `bar`, `/foo/bar`, ``},
@@ -29,18 +29,18 @@ func TestNormaliseWorkdir(t *testing.T) {
 		{"linux", `\a`, `b\c`, `/a/b/c`, ``},
 	}
 	for _, i := range tests {
-		r, e := normaliseWorkdir(i.platform, i.current, i.requested)
+		r, e := normalizeWorkdir(i.platform, i.current, i.requested)
 
 		if i.etext != "" && e == nil {
-			t.Fatalf("TestNormaliseWorkingDir Expected error %s for '%s' '%s', got no error", i.etext, i.current, i.requested)
+			t.Fatalf("TestNormalizeWorkingDir Expected error %s for '%s' '%s', got no error", i.etext, i.current, i.requested)
 		}
 
 		if i.etext != "" && e.Error() != i.etext {
-			t.Fatalf("TestNormaliseWorkingDir Expected error %s for '%s' '%s', got %s", i.etext, i.current, i.requested, e.Error())
+			t.Fatalf("TestNormalizeWorkingDir Expected error %s for '%s' '%s', got %s", i.etext, i.current, i.requested, e.Error())
 		}
 
 		if r != i.expected {
-			t.Fatalf("TestNormaliseWorkingDir Expected '%s' for '%s' '%s', got '%s'", i.expected, i.current, i.requested, r)
+			t.Fatalf("TestNormalizeWorkingDir Expected '%s' for '%s' '%s', got '%s'", i.expected, i.current, i.requested, r)
 		}
 	}
 }

+ 1 - 1
builder/dockerfile/internals.go

@@ -140,7 +140,7 @@ func (b *Builder) performCopy(state *dispatchState, inst copyInstruction) error
 func createDestInfo(workingDir string, inst copyInstruction, imageMount *imageMount) (copyInfo, error) {
 	// Twiddle the destination when it's a relative path - meaning, make it
 	// relative to the WORKINGDIR
-	dest, err := normaliseDest(workingDir, inst.dest)
+	dest, err := normalizeDest(workingDir, inst.dest)
 	if err != nil {
 		return copyInfo{}, errors.Wrapf(err, "invalid %s", inst.cmdName)
 	}

+ 2 - 2
builder/dockerfile/internals_unix.go

@@ -10,9 +10,9 @@ import (
 	"github.com/docker/docker/pkg/system"
 )
 
-// normaliseDest normalises the destination of a COPY/ADD command in a
+// normalizeDest normalizes the destination of a COPY/ADD command in a
 // platform semantically consistent way.
-func normaliseDest(workingDir, requested string) (string, error) {
+func normalizeDest(workingDir, requested string) (string, error) {
 	dest := filepath.FromSlash(requested)
 	endsInSlash := strings.HasSuffix(requested, string(os.PathSeparator))
 	if !system.IsAbs(requested) {

+ 2 - 2
builder/dockerfile/internals_windows.go

@@ -10,9 +10,9 @@ import (
 	"github.com/pkg/errors"
 )
 
-// normaliseDest normalises the destination of a COPY/ADD command in a
+// normalizeDest normalizes the destination of a COPY/ADD command in a
 // platform semantically consistent way.
-func normaliseDest(workingDir, requested string) (string, error) {
+func normalizeDest(workingDir, requested string) (string, error) {
 	dest := filepath.FromSlash(requested)
 	endsInSlash := strings.HasSuffix(dest, string(os.PathSeparator))
 

+ 2 - 2
builder/dockerfile/internals_windows_test.go

@@ -10,7 +10,7 @@ import (
 	"github.com/stretchr/testify/assert"
 )
 
-func TestNormaliseDest(t *testing.T) {
+func TestNormalizeDest(t *testing.T) {
 	tests := []struct{ current, requested, expected, etext string }{
 		{``, `D:\`, ``, `Windows does not support destinations not on the system drive (C:)`},
 		{``, `e:/`, ``, `Windows does not support destinations not on the system drive (C:)`},
@@ -40,7 +40,7 @@ func TestNormaliseDest(t *testing.T) {
 	}
 	for _, testcase := range tests {
 		msg := fmt.Sprintf("Input: %s, %s", testcase.current, testcase.requested)
-		actual, err := normaliseDest(testcase.current, testcase.requested)
+		actual, err := normalizeDest(testcase.current, testcase.requested)
 		if testcase.etext == "" {
 			if !assert.NoError(t, err, msg) {
 				continue

+ 1 - 1
integration-cli/docker_cli_commit_test.go

@@ -122,7 +122,7 @@ func (s *DockerSuite) TestCommitChange(c *check.C) {
 	imageID = strings.TrimSpace(imageID)
 
 	prefix, slash := getPrefixAndSlashFromDaemonPlatform()
-	prefix = strings.ToUpper(prefix) // Force C: as that's how WORKDIR is normalised on Windows
+	prefix = strings.ToUpper(prefix) // Force C: as that's how WORKDIR is normalized on Windows
 	expected := map[string]string{
 		"Config.ExposedPorts": "map[8080/tcp:{}]",
 		"Config.Env":          "[DEBUG=true test=1 PATH=/foo]",

+ 5 - 5
volume/store/store.go

@@ -188,7 +188,7 @@ func (s *VolumeStore) List() ([]volume.Volume, []string, error) {
 	var out []volume.Volume
 
 	for _, v := range vols {
-		name := normaliseVolumeName(v.Name())
+		name := normalizeVolumeName(v.Name())
 
 		s.locks.Lock(name)
 		storedV, exists := s.getNamed(name)
@@ -269,7 +269,7 @@ func (s *VolumeStore) list() ([]volume.Volume, []string, error) {
 // CreateWithRef creates a volume with the given name and driver and stores the ref
 // This ensures there's no race between creating a volume and then storing a reference.
 func (s *VolumeStore) CreateWithRef(name, driverName, ref string, opts, labels map[string]string) (volume.Volume, error) {
-	name = normaliseVolumeName(name)
+	name = normalizeVolumeName(name)
 	s.locks.Lock(name)
 	defer s.locks.Unlock(name)
 
@@ -432,7 +432,7 @@ func (s *VolumeStore) create(name, driverName string, opts, labels map[string]st
 // This is just like Get(), but we store the reference while holding the lock.
 // This makes sure there are no races between checking for the existence of a volume and adding a reference for it
 func (s *VolumeStore) GetWithRef(name, driverName, ref string) (volume.Volume, error) {
-	name = normaliseVolumeName(name)
+	name = normalizeVolumeName(name)
 	s.locks.Lock(name)
 	defer s.locks.Unlock(name)
 
@@ -455,7 +455,7 @@ func (s *VolumeStore) GetWithRef(name, driverName, ref string) (volume.Volume, e
 
 // Get looks if a volume with the given name exists and returns it if so
 func (s *VolumeStore) Get(name string) (volume.Volume, error) {
-	name = normaliseVolumeName(name)
+	name = normalizeVolumeName(name)
 	s.locks.Lock(name)
 	defer s.locks.Unlock(name)
 
@@ -558,7 +558,7 @@ func lookupVolume(driverName, volumeName string) (volume.Volume, error) {
 
 // Remove removes the requested volume. A volume is not removed if it has any refs
 func (s *VolumeStore) Remove(v volume.Volume) error {
-	name := normaliseVolumeName(v.Name())
+	name := normalizeVolumeName(v.Name())
 	s.locks.Lock(name)
 	defer s.locks.Unlock(name)
 

+ 2 - 2
volume/store/store_unix.go

@@ -2,8 +2,8 @@
 
 package store
 
-// normaliseVolumeName is a platform specific function to normalise the name
+// normalizeVolumeName is a platform specific function to normalize the name
 // of a volume. This is a no-op on Unix-like platforms
-func normaliseVolumeName(name string) string {
+func normalizeVolumeName(name string) string {
 	return name
 }

+ 2 - 2
volume/store/store_windows.go

@@ -2,11 +2,11 @@ package store
 
 import "strings"
 
-// normaliseVolumeName is a platform specific function to normalise the name
+// normalizeVolumeName is a platform specific function to normalize the name
 // of a volume. On Windows, as NTFS is case insensitive, under
 // c:\ProgramData\Docker\Volumes\, the folders John and john would be synonymous.
 // Hence we can't allow the volume "John" and "john" to be created as separate
 // volumes.
-func normaliseVolumeName(name string) string {
+func normalizeVolumeName(name string) string {
 	return strings.ToLower(name)
 }