Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion remotes/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var ErrNotFound = errors.New("not found")
func NewFileProvider(file File) StoreProvider {
return &fileProvider{
file: file,
downloader: NewDownloadGZIPFromZSDT(file),
downloader: NewDownloadGZIPFromZSTD(file),
}
}

Expand Down
15 changes: 11 additions & 4 deletions remotes/file_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,29 @@ func DownloadFetch(ctx context.Context, d Downloader, desc ocispec.Descriptor) (
return nil, fmt.Errorf("digest %s not found: %w", desc.Digest, ErrNotFound)
}

// NewDownloadGZIPFromZSDT is typo of NewDownloadGZIPFromZSTD
// Deprecated, use NewDownloadGZIPFromZSTD
func NewDownloadGZIPFromZSDT(f File) Downloader {
return &downloadGZIPFromZSDT{file: f}
return &downloadGZIPFromZSTD{file: f}
}

type downloadGZIPFromZSDT struct {
// NewDownloadGZIPFromZSTD convert zstd blob to gzip format
func NewDownloadGZIPFromZSTD(f File) Downloader {
return &downloadGZIPFromZSTD{file: f}
}

type downloadGZIPFromZSTD struct {
file File
}

func (d *downloadGZIPFromZSDT) Support(_ context.Context, desc ocispec.Descriptor, downloadURL string) bool {
func (d *downloadGZIPFromZSTD) Support(_ context.Context, desc ocispec.Descriptor, downloadURL string) bool {
// NOTE: to reproducible generate gzip from zstd, gzip header should
// always be empty, and the default compress level should be used
u, err := url.ParseRequestURI(downloadURL)
return err == nil && u.Scheme == URISchemeZstd && desc.MediaType == ocispec.MediaTypeImageLayerGzip
}

func (d *downloadGZIPFromZSDT) Download(_ context.Context, _ ocispec.Descriptor, downloadURL string) (io.ReadCloser, error) {
func (d *downloadGZIPFromZSTD) Download(_ context.Context, _ ocispec.Descriptor, downloadURL string) (io.ReadCloser, error) {
u, err := url.ParseRequestURI(downloadURL)
if err != nil {
return nil, fmt.Errorf("invalid url %s: %w", downloadURL, err)
Expand Down
4 changes: 2 additions & 2 deletions remotes/file_download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ import (
"github.com/everoute/container/remotes"
)

func TestDownloadGZIPFromZSDT(t *testing.T) {
func TestDownloadGZIPFromZSTD(t *testing.T) {
RegisterTestingT(t)

ctx := context.Background()
f := remotes.OpenFunc(func() (io.ReadCloser, error) { return os.Open("testdata/example-zstd.tar") })
d := remotes.NewDownloadGZIPFromZSDT(f)
d := remotes.NewDownloadGZIPFromZSTD(f)

desc := ocispec.Descriptor{
MediaType: ocispec.MediaTypeImageLayerGzip,
Expand Down
Loading