Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 196387f

Browse files
Wrap tar errors with some context
Signed-off-by: Silvin Lubecki <silvin.lubecki@docker.com>
1 parent d8fe337 commit 196387f

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

internal/packager/packing.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package packager
22

33
import (
44
"archive/tar"
5-
"errors"
65
"fmt"
76
"io"
87
"io/ioutil"
@@ -12,6 +11,7 @@ import (
1211
"github.com/docker/app/internal"
1312
"github.com/docker/app/types"
1413
"github.com/docker/docker/pkg/archive"
14+
"github.com/pkg/errors"
1515
)
1616

1717
var dockerFile = `FROM docker/cnab-app-base:` + internal.Version + `
@@ -51,26 +51,26 @@ func PackInvocationImageContext(app *types.App, target io.Writer) error {
5151
return errors.New("app should have one and only one compose file")
5252
}
5353
if len(app.ParametersRaw()) != 1 {
54-
return errors.New("app should have one and only parameters file")
54+
return errors.New("app should have one and only one parameters file")
5555
}
5656
if err := tarAddBytes(tarout, "Dockerfile", []byte(dockerFile)); err != nil {
57-
return err
57+
return errors.Wrap(err, "failed to add Dockerfile to the invocation image build context")
5858
}
5959
if err := tarAddBytes(tarout, ".dockerignore", []byte(dockerIgnore)); err != nil {
60-
return err
60+
return errors.Wrap(err, "failed to add .dockerignore to the invocation image build context")
6161
}
6262
if err := tarAddBytes(tarout, prefix+internal.MetadataFileName, app.MetadataRaw()); err != nil {
63-
return err
63+
return errors.Wrapf(err, "failed to add %q to the invocation image build context", prefix+internal.MetadataFileName)
6464
}
6565
if err := tarAddBytes(tarout, prefix+internal.ComposeFileName, app.Composes()[0]); err != nil {
66-
return err
66+
return errors.Wrapf(err, "failed to add %q to the invocation image build context", prefix+internal.ComposeFileName)
6767
}
6868
if err := tarAddBytes(tarout, prefix+internal.ParametersFileName, app.ParametersRaw()[0]); err != nil {
69-
return err
69+
return errors.Wrapf(err, "failed to add %q to the invocation image build context", prefix+internal.ParametersFileName)
7070
}
7171
for _, attachment := range app.Attachments() {
7272
if err := tarAdd(tarout, prefix+attachment.Path(), filepath.Join(app.Path, attachment.Path())); err != nil {
73-
return err
73+
return errors.Wrapf(err, "failed to add attachment %q to the invocation image build context", prefix+attachment.Path())
7474
}
7575
}
7676
return nil

0 commit comments

Comments
 (0)