Skip to content

Commit

Permalink
change default mappers behavior to failsafe (to filestore or nil)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshrwolf committed Dec 8, 2021
1 parent a683145 commit 97341fd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/getter/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
10 changes: 5 additions & 5 deletions internal/mapper/mappers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
case consts.ChartLayerMediaType, consts.ChartConfigMediaType:
s := NewMapperFileStore(root, Chart())
defer s.Close()
return s, nil

case consts.ChartLayerMediaType, consts.ChartConfigMediaType:
s := NewMapperFileStore(root, Chart())
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 {
Expand Down

0 comments on commit 97341fd

Please sign in to comment.