Ensure BaseName of Stage is not blank

Related: https://github.com/moby/moby/issues/37325

Signed-off-by: Yuichiro Kaneko <spiketeika@gmail.com>
docker-18.09
Yuichiro Kaneko 2018-06-28 08:46:29 +09:00
parent 3f8ab160d5
commit 813575f62a
2 changed files with 11 additions and 0 deletions

View File

@ -85,6 +85,9 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State,
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
if name == "" {
return nil, nil, errors.Errorf("base name (%s) should not be blank", st.BaseName)
}
st.BaseName = name st.BaseName = name
ds := &dispatchState{ ds := &dispatchState{

View File

@ -41,4 +41,12 @@ COPY --from=0 f2 /
Target: "nosuch", Target: "nosuch",
}) })
assert.Error(t, err) assert.Error(t, err)
df = `FROM "" AS foo`
_, _, err = Dockerfile2LLB(appcontext.Context(), []byte(df), ConvertOpt{})
assert.Error(t, err)
df = `FROM ${BLANK} AS foo`
_, _, err = Dockerfile2LLB(appcontext.Context(), []byte(df), ConvertOpt{})
assert.Error(t, err)
} }