| ... | ... |
@@ -2,6 +2,7 @@ package docker |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"encoding/json" |
| 5 |
+ "errors" |
|
| 5 | 6 |
"fmt" |
| 6 | 7 |
"github.com/dotcloud/docker/archive" |
| 7 | 8 |
"github.com/dotcloud/docker/auth" |
| ... | ... |
@@ -16,6 +17,10 @@ import ( |
| 16 | 16 |
"strings" |
| 17 | 17 |
) |
| 18 | 18 |
|
| 19 |
+var ( |
|
| 20 |
+ ErrDockerfileEmpty = errors.New("Dockerfile cannot be empty")
|
|
| 21 |
+) |
|
| 22 |
+ |
|
| 19 | 23 |
type BuildFile interface {
|
| 20 | 24 |
Build(io.Reader) (string, error) |
| 21 | 25 |
CmdFrom(string) error |
| ... | ... |
@@ -529,6 +534,9 @@ func (b *buildFile) Build(context io.Reader) (string, error) {
|
| 529 | 529 |
if err != nil {
|
| 530 | 530 |
return "", err |
| 531 | 531 |
} |
| 532 |
+ if len(fileBytes) == 0 {
|
|
| 533 |
+ return "", ErrDockerfileEmpty |
|
| 534 |
+ } |
|
| 532 | 535 |
dockerfile := string(fileBytes) |
| 533 | 536 |
dockerfile = lineContinuation.ReplaceAllString(dockerfile, "") |
| 534 | 537 |
stepN := 0 |
| ... | ... |
@@ -630,3 +630,11 @@ func TestBuildFails(t *testing.T) {
|
| 630 | 630 |
t.Fatalf("StatusCode %d unexpected, should be 23", sterr.Code)
|
| 631 | 631 |
} |
| 632 | 632 |
} |
| 633 |
+ |
|
| 634 |
+func TestBuildFailsDockerfileEmpty(t *testing.T) {
|
|
| 635 |
+ _, err := buildImage(testContextTemplate{``, nil, nil}, t, nil, true)
|
|
| 636 |
+ |
|
| 637 |
+ if err != docker.ErrDockerfileEmpty {
|
|
| 638 |
+ t.Fatal("Expected: %v, got: %v", docker.ErrDockerfileEmpty, err)
|
|
| 639 |
+ } |
|
| 640 |
+} |