change default mappers behavior to failsafe (to filestore or nil)

This commit is contained in:
Josh Wolf
2021-12-08 09:25:01 -07:00
parent a6831454e5
commit 97341fd9b1
2 changed files with 7 additions and 7 deletions
+1 -1
View File
@@ -33,7 +33,7 @@ func (d directory) Open(ctx context.Context, u *url.URL) (io.ReadCloser, error)
defer zw.Close()
tarDigester := digest.Canonical.Digester()
if err := tarDir(d.path(u), d.Name(u), io.MultiWriter(zw, tarDigester.Hash()), true); err != nil {
if err := tarDir(d.path(u), d.Name(u), io.MultiWriter(zw, tarDigester.Hash()), false); err != nil {
return nil, err
}
+6 -6
View File
@@ -13,23 +13,23 @@ type Fn func(desc ocispec.Descriptor) (string, error)
// FromManifest will return the appropriate content store given a reference and source type adequate for storing the results on disk
func FromManifest(manifest ocispec.Manifest, root string) (target.Target, error) {
// TODO: Don't rely solely on config mediatype
switch manifest.Config.MediaType {
case consts.DockerConfigJSON, consts.OCIManifestSchema1:
s := NewMapperFileStore(root, Images())
defer s.Close()
return s, nil
case consts.FileLocalConfigMediaType:
s := NewMapperFileStore(root, nil)
defer s.Close()
return s, nil
case consts.ChartLayerMediaType, consts.ChartConfigMediaType:
s := NewMapperFileStore(root, Chart())
defer s.Close()
return s, nil
default:
s := NewMapperFileStore(root, nil)
defer s.Close()
return s, nil
}
return nil, fmt.Errorf("could not identify mapper from manifest with media type [%s]", manifest.MediaType)
}
func Images() map[string]Fn {