moby/vendor/github.com/cpuguy83/tar2go/fs.go
Brian Goff 1e55ace875 Add oci index and layout files to exported tars
This makes the output of `docker save` fully OCI compliant.

When using the containerd image store, this code is not used. That
exporter will just use containerd's export method and should give us the
output we want for multi-arch images.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2023-05-28 20:35:14 +00:00

30 lines
562 B
Go

package tar2go
import (
"io/fs"
)
var (
_ fs.FS = &filesystem{}
_ fs.File = &file{}
)
type filesystem struct {
idx *Index
}
func (f *filesystem) Open(name string) (fs.File, error) {
idx, err := f.idx.indexWithLock(name)
if err != nil {
return nil, &fs.PathError{Path: name, Op: "open", Err: err}
}
return newFile(idx), nil
}
func (f *filesystem) Stat(name string) (fs.FileInfo, error) {
idx, err := f.idx.indexWithLock(name)
if err != nil {
return nil, &fs.PathError{Path: name, Op: "stat", Err: err}
}
return &fileinfo{h: idx.hdr}, nil
}