diff --git a/remotes/file.go b/remotes/file.go index 72a69b5..ee4aff7 100644 --- a/remotes/file.go +++ b/remotes/file.go @@ -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), } } diff --git a/remotes/file_download.go b/remotes/file_download.go index 10772f5..8b80942 100644 --- a/remotes/file_download.go +++ b/remotes/file_download.go @@ -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) diff --git a/remotes/file_download_test.go b/remotes/file_download_test.go index 3a8d383..4da53a3 100644 --- a/remotes/file_download_test.go +++ b/remotes/file_download_test.go @@ -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,