Wrap tar errors with some context
@@ -2,7 +2,6 @@ package packager
import (
"archive/tar"
- "errors"
"fmt"
"io"
"io/ioutil"
@@ -12,6 +11,7 @@ import (
"github.com/docker/app/internal"
"github.com/docker/app/types"
"github.com/docker/docker/pkg/archive"
+ "github.com/pkg/errors"
)
var dockerFile = `FROM docker/cnab-app-base:` + internal.Version + `
@@ -51,26 +51,26 @@ func PackInvocationImageContext(app *types.App, target io.Writer) error {
return errors.New("app should have one and only one compose file")
}
if len(app.ParametersRaw()) != 1 {
- return errors.New("app should have one and only parameters file")
+ return errors.New("app should have one and only one parameters file")
}
if err := tarAddBytes(tarout, "Dockerfile", []byte(dockerFile)); err != nil {
- return err
+ return errors.Wrap(err, "failed to add Dockerfile to the invocation image build context")
}
if err := tarAddBytes(tarout, ".dockerignore", []byte(dockerIgnore)); err != nil {
- return err
+ return errors.Wrap(err, "failed to add .dockerignore to the invocation image build context")
}
if err := tarAddBytes(tarout, prefix+internal.MetadataFileName, app.MetadataRaw()); err != nil {
- return err
+ return errors.Wrapf(err, "failed to add %q to the invocation image build context", prefix+internal.MetadataFileName)
}
if err := tarAddBytes(tarout, prefix+internal.ComposeFileName, app.Composes()[0]); err != nil {
- return err
+ return errors.Wrapf(err, "failed to add %q to the invocation image build context", prefix+internal.ComposeFileName)
}
if err := tarAddBytes(tarout, prefix+internal.ParametersFileName, app.ParametersRaw()[0]); err != nil {
- return err
+ return errors.Wrapf(err, "failed to add %q to the invocation image build context", prefix+internal.ParametersFileName)
}
for _, attachment := range app.Attachments() {
if err := tarAdd(tarout, prefix+attachment.Path(), filepath.Join(app.Path, attachment.Path())); err != nil {
- return err
+ return errors.Wrapf(err, "failed to add attachment %q to the invocation image build context", prefix+attachment.Path())
}
}
return nil
