Merge pull request #470 from yui-knk/ensure_arg_is_not_blank

Ensure BaseName of Stage is not blank
docker-18.09
Tõnis Tiigi 2018-06-28 10:32:11 -07:00 committed by GitHub
commit 3b9737dd5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

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

View File

@ -41,4 +41,12 @@ COPY --from=0 f2 /
Target: "nosuch",
})
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)
}