mirror of https://github.com/docker/docs.git
Merge pull request #1793 from reds/master
From FIXME: local path for ADD
This commit is contained in:
commit
58281b4f18
|
@ -292,7 +292,7 @@ func (b *buildFile) addContext(container *Container, orig, dest string) error {
|
||||||
}
|
}
|
||||||
fi, err := os.Stat(origPath)
|
fi, err := os.Stat(origPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return fmt.Errorf("%s: no such file or directory", orig)
|
||||||
}
|
}
|
||||||
if fi.IsDir() {
|
if fi.IsDir() {
|
||||||
if err := CopyWithTar(origPath, destPath); err != nil {
|
if err := CopyWithTar(origPath, destPath); err != nil {
|
||||||
|
|
|
@ -483,3 +483,51 @@ func TestForbiddenContextPath(t *testing.T) {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBuildADDFileNotFound(t *testing.T) {
|
||||||
|
runtime, err := newTestRuntime()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer nuke(runtime)
|
||||||
|
|
||||||
|
srv := &Server{
|
||||||
|
runtime: runtime,
|
||||||
|
pullingPool: make(map[string]struct{}),
|
||||||
|
pushingPool: make(map[string]struct{}),
|
||||||
|
}
|
||||||
|
|
||||||
|
context := testContextTemplate{`
|
||||||
|
from {IMAGE}
|
||||||
|
add foo /usr/local/bar
|
||||||
|
`,
|
||||||
|
nil, nil}
|
||||||
|
|
||||||
|
httpServer, err := mkTestingFileServer(context.remoteFiles)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
defer httpServer.Close()
|
||||||
|
|
||||||
|
idx := strings.LastIndex(httpServer.URL, ":")
|
||||||
|
if idx < 0 {
|
||||||
|
t.Fatalf("could not get port from test http server address %s", httpServer.URL)
|
||||||
|
}
|
||||||
|
port := httpServer.URL[idx+1:]
|
||||||
|
|
||||||
|
ip := srv.runtime.networkManager.bridgeNetwork.IP
|
||||||
|
dockerfile := constructDockerfile(context.dockerfile, ip, port)
|
||||||
|
|
||||||
|
buildfile := NewBuildFile(srv, ioutil.Discard, false, true)
|
||||||
|
_, err = buildfile.Build(mkTestContext(dockerfile, context.files, t))
|
||||||
|
|
||||||
|
if err == nil {
|
||||||
|
t.Log("Error should not be nil")
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
|
||||||
|
if err.Error() != "foo: no such file or directory" {
|
||||||
|
t.Logf("Error message is not expected: %s", err.Error())
|
||||||
|
t.Fail()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue