Skip to content

Commit

Permalink
Merge pull request #163 from crazy-max/warn-unknown-format
Browse files Browse the repository at this point in the history
warn on unknown blob format
  • Loading branch information
crazy-max authored Sep 15, 2023
2 parents c4b752d + 1f49912 commit 262b630
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ jobs:
matrix:
include:
-
image: "crazymax/buildx-pkg:latest"
image: "dockereng/packaging:buildx-v0.11.1"
all: "true"
loglevel: "debug"
-
image: "crazymax/buildx-pkg:latest"
image: "dockereng/packaging:buildx-v0.11.1"
all: "true"
wrap: "true"
loglevel: "debug"
Expand Down Expand Up @@ -131,8 +131,8 @@ jobs:
-
name: Create docker archive
run: |
docker pull crazymax/buildx-pkg:latest
docker save crazymax/buildx-pkg:latest > archive.tar
docker pull dockereng/packaging:buildx-v0.11.1
docker save dockereng/packaging:buildx-v0.11.1 > archive.tar
-
name: Run
run: |
Expand Down
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@ Documentation can be found at https://crazymax.dev/undock/

## Contributing

Want to contribute? Awesome! The most basic way to show your support is to star the project, or to raise issues. If
you want to open a pull request, please read the [contributing guidelines](.github/CONTRIBUTING.md).

You can also support this project by [**becoming a sponsor on GitHub**](https://github.com/sponsors/crazy-max) or by
making a [Paypal donation](https://www.paypal.me/crazyws) to ensure this journey continues indefinitely!
Want to contribute? Awesome! The most basic way to show your support is to star
the project, or to raise issues. You can also support this project by [**becoming a sponsor on GitHub**](https://github.com/sponsors/crazy-max)
or by making a [PayPal donation](https://www.paypal.me/crazyws) to ensure this
journey continues indefinitely!

Thanks again for your support, it is much appreciated! :pray:

Expand Down
9 changes: 4 additions & 5 deletions internal/extractor/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ func ExtractBlob(filename string, dest string, opts ExtractBlobOpts) error {

format, r, err := archiver.Identify(filename, dt)
if err != nil {
return err
opts.Logger.Warn().Msg("Blob format not recognized")
return nil
}
opts.Logger.Debug().Msgf("Blob format %s detected", format.Name())

Expand Down Expand Up @@ -72,15 +73,15 @@ func ExtractBlob(filename string, dest string, opts ExtractBlobOpts) error {
pathsInArchive = nil
}

err = u.Extract(opts.Context, r, pathsInArchive, func(ctx context.Context, f archiver.File) error {
return u.Extract(opts.Context, r, pathsInArchive, func(ctx context.Context, f archiver.File) error {
if f.FileInfo.IsDir() {
opts.Logger.Trace().Msgf("Extracting %s", f.NameInArchive)
} else {
opts.Logger.Debug().Msgf("Extracting %s", f.NameInArchive)
}

path := filepath.Join(dest, f.NameInArchive)
if err = os.MkdirAll(filepath.Dir(path), 0755); err != nil {
if err = os.MkdirAll(filepath.Dir(path), 0o700); err != nil {
return err
}

Expand All @@ -95,8 +96,6 @@ func ExtractBlob(filename string, dest string, opts ExtractBlobOpts) error {
return fmt.Errorf("cannot handle file mode: %v", f.FileInfo.Mode())
}
})

return err
}

func writeFile(ctx context.Context, path string, f archiver.File) error {
Expand Down
8 changes: 4 additions & 4 deletions internal/extractor/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ func (c *Client) Extract() error {
if !c.cli.Wrap && len(mans) > 1 {
dest = path.Join(c.cli.Dist, fmt.Sprintf("%s_%s%s", mane.platform.OS, mane.platform.Architecture, mane.platform.Variant))
}
if err := os.MkdirAll(dest, 0o700); err != nil {
return errors.Wrapf(err, "failed to create destination folder %q", dest)
}
for _, layer := range mane.manifest.LayerInfos() {
sublogger := c.logger.With().Str("platform", platforms.Format(mane.platform)).Str("blob", layer.Digest.String()).Logger()
sublogger := c.logger.With().
Str("platform", platforms.Format(mane.platform)).
Str("media-type", layer.MediaType).
Str("blob", layer.Digest.String()).Logger()
if err = extractor.ExtractBlob(path.Join(cachedir, "blobs", layer.Digest.Algorithm().String(), layer.Digest.Hex()), dest, extractor.ExtractBlobOpts{
Context: c.ctx,
Logger: sublogger,
Expand Down

0 comments on commit 262b630

Please sign in to comment.