Show err msg on empty 'scratch' Dockerfile
If you have a Dockefile with just: FROM scratch An error is generated but its never shown to the CLI. This PR fixes that. Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
parent
d14751bf30
commit
1654dfdf14
2 changed files with 13 additions and 1 deletions
|
@ -163,7 +163,7 @@ func (b *Builder) Run(context io.Reader) (string, error) {
|
|||
}
|
||||
|
||||
if b.image == "" {
|
||||
return "", fmt.Errorf("No image was generated. Is your Dockerfile empty?\n")
|
||||
return "", fmt.Errorf("No image was generated. Is your Dockerfile empty?")
|
||||
}
|
||||
|
||||
fmt.Fprintf(b.OutStream, "Successfully built %s\n", utils.TruncateID(b.image))
|
||||
|
|
|
@ -4870,3 +4870,15 @@ func TestBuildMissingArgs(t *testing.T) {
|
|||
|
||||
logDone("build - verify missing args")
|
||||
}
|
||||
|
||||
func TestBuildEmptyScratch(t *testing.T) {
|
||||
defer deleteImages("sc")
|
||||
_, out, err := buildImageWithOut("sc", "FROM scratch", true)
|
||||
if err == nil {
|
||||
t.Fatalf("Build was supposed to fail")
|
||||
}
|
||||
if !strings.Contains(out, "No image was generated") {
|
||||
t.Fatalf("Wrong error message: %v", out)
|
||||
}
|
||||
logDone("build - empty scratch Dockerfile")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue