Skip to content

Commit

Permalink
Merge pull request #2183 from tonistiigi/dockerfile-config-error
Browse files Browse the repository at this point in the history
dockerfile: ensure config resolve errors keep source location
  • Loading branch information
AkihiroSuda committed Jun 17, 2021
2 parents 0164c06 + 111153e commit b6b07d1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions frontend/dockerfile/dockerfile2llb/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,15 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State,
continue
}
func(i int, d *dispatchState) {
eg.Go(func() error {
eg.Go(func() (err error) {
defer func() {
if err != nil {
err = parser.WithLocation(err, d.stage.Location)
}
}()
ref, err := reference.ParseNormalizedNamed(d.stage.BaseName)
if err != nil {
return parser.WithLocation(errors.Wrapf(err, "failed to parse stage name %q", d.stage.BaseName), d.stage.Location)
return errors.Wrapf(err, "failed to parse stage name %q", d.stage.BaseName)
}
platform := d.platform
if platform == nil {
Expand All @@ -250,11 +255,11 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State,
LogName: fmt.Sprintf("%s load metadata for %s", prefix, d.stage.BaseName),
})
if err != nil {
return err
return errors.Wrap(err, d.stage.BaseName)
}
var img Image
if err := json.Unmarshal(dt, &img); err != nil {
return err
return errors.Wrap(err, "failed to parse image config")
}
img.Created = nil
// if there is no explicit target platform, try to match based on image config
Expand Down

0 comments on commit b6b07d1

Please sign in to comment.