소스 검색

builder/normalizeWorkdir: Always return cleaned path

The `normalizeWorkdir` function has two branches, one that returns a
result of `filepath.Join` which always returns a cleaned path, and
another one where the input string is returned unmodified.

To make these two outputs consistent, also clean the path in the second
branch.

This also makes the cleaning of the container workdir explicit in the
`normalizeWorkdir` function instead of relying on the
`SetupWorkingDirectory` to mutate it.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Paweł Gronowski 1 년 전
부모
커밋
a4d5b6b4d0
2개의 변경된 파일2개의 추가작업 그리고 2개의 파일을 삭제
  1. 1 1
      builder/dockerfile/dispatchers_unix.go
  2. 1 1
      integration-cli/docker_cli_build_test.go

+ 1 - 1
builder/dockerfile/dispatchers_unix.go

@@ -22,7 +22,7 @@ func normalizeWorkdir(_ string, current string, requested string) (string, error
 	if !filepath.IsAbs(requested) {
 	if !filepath.IsAbs(requested) {
 		return filepath.Join(string(os.PathSeparator), current, requested), nil
 		return filepath.Join(string(os.PathSeparator), current, requested), nil
 	}
 	}
-	return requested, nil
+	return filepath.Clean(requested), nil
 }
 }
 
 
 // resolveCmdLine takes a command line arg set and optionally prepends a platform-specific
 // resolveCmdLine takes a command line arg set and optionally prepends a platform-specific

+ 1 - 1
integration-cli/docker_cli_build_test.go

@@ -4296,7 +4296,7 @@ func (s *DockerCLIBuildSuite) TestBuildBuildTimeArgExpansion(c *testing.T) {
 	imgName := "bldvarstest"
 	imgName := "bldvarstest"
 
 
 	wdVar := "WDIR"
 	wdVar := "WDIR"
-	wdVal := "/tmp/"
+	wdVal := "/tmp"
 	addVar := "AFILE"
 	addVar := "AFILE"
 	addVal := "addFile"
 	addVal := "addFile"
 	copyVar := "CFILE"
 	copyVar := "CFILE"