From 06318f75ac9514c502bf28234a2d70fab14b8967 Mon Sep 17 00:00:00 2001 From: Jeff Zvier Date: Tue, 11 Aug 2020 16:49:11 +0800 Subject: [PATCH] parser: modify tips when no instruction found in Dockerfile Signed-off-by: liuzekun --- builder/dockerfile/parser/parser.go | 2 +- builder/dockerfile/parser/parser_test.go | 2 +- daemon/build.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/builder/dockerfile/parser/parser.go b/builder/dockerfile/parser/parser.go index ad04510..3041f9b 100644 --- a/builder/dockerfile/parser/parser.go +++ b/builder/dockerfile/parser/parser.go @@ -184,7 +184,7 @@ func getPageName(line *parser.Line, pageNum int) (string, error) { func constructPages(lines []*parser.Line, onbuild bool) ([]*parser.Page, error) { if len(lines) == 0 { - return nil, errors.New("dockerfile content is empty") + return nil, errors.New("no instructions in Dockerfile") } var ( diff --git a/builder/dockerfile/parser/parser_test.go b/builder/dockerfile/parser/parser_test.go index 00935f4..4f3a49c 100644 --- a/builder/dockerfile/parser/parser_test.go +++ b/builder/dockerfile/parser/parser_test.go @@ -142,7 +142,7 @@ func TestParse(t *testing.T) { { name: "busybox_with_empty_content", isErr: true, - errStr: "dockerfile content is empty", + errStr: "no instructions in Dockerfile", }, { name: "busybox_no_command", diff --git a/daemon/build.go b/daemon/build.go index acd689b..730b6b1 100644 --- a/daemon/build.go +++ b/daemon/build.go @@ -68,7 +68,7 @@ func (b *Backend) Build(req *pb.BuildRequest, stream pb.Control_BuildServer) (er // the pipeFile, which will cause frontend hangs forever. // so if the output type is archive(pipeFile is not empty string) and any error occurred, we write the error // message into the pipe to make the goroutine move on instead of hangs. - if err != nil && pipeWrapper.PipeFile != "" { + if err != nil && pipeWrapper != nil { pipeWrapper.Close() if perr := ioutil.WriteFile(pipeWrapper.PipeFile, []byte(err.Error()), constant.DefaultRootFileMode); perr != nil { logrus.WithField(util.LogKeySessionID, req.BuildID).Warnf("Write error [%v] in to pipe file failed: %v", err, perr) -- GitLab