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>
... | ... |
@@ -163,7 +163,7 @@ func (b *Builder) Run(context io.Reader) (string, error) { |
163 | 163 |
} |
164 | 164 |
|
165 | 165 |
if b.image == "" { |
166 |
- return "", fmt.Errorf("No image was generated. Is your Dockerfile empty?\n") |
|
166 |
+ return "", fmt.Errorf("No image was generated. Is your Dockerfile empty?") |
|
167 | 167 |
} |
168 | 168 |
|
169 | 169 |
fmt.Fprintf(b.OutStream, "Successfully built %s\n", utils.TruncateID(b.image)) |
... | ... |
@@ -4870,3 +4870,15 @@ func TestBuildMissingArgs(t *testing.T) { |
4870 | 4870 |
|
4871 | 4871 |
logDone("build - verify missing args") |
4872 | 4872 |
} |
4873 |
+ |
|
4874 |
+func TestBuildEmptyScratch(t *testing.T) { |
|
4875 |
+ defer deleteImages("sc") |
|
4876 |
+ _, out, err := buildImageWithOut("sc", "FROM scratch", true) |
|
4877 |
+ if err == nil { |
|
4878 |
+ t.Fatalf("Build was supposed to fail") |
|
4879 |
+ } |
|
4880 |
+ if !strings.Contains(out, "No image was generated") { |
|
4881 |
+ t.Fatalf("Wrong error message: %v", out) |
|
4882 |
+ } |
|
4883 |
+ logDone("build - empty scratch Dockerfile") |
|
4884 |
+} |