Documentation
¶
Overview ¶
Package folder is the mounts driver for a folder on the server's disk. Its mounts are live and writable, and have host paths. Only the server's configuration makes folder mounts (the registry refuses one from Create), so a client never picks the folder.
Every operation refuses links anywhere in a path, so a link inside the folder can't reach a file outside it, or a second name for a file inside it. Listings leave out links, devices and anything else that isn't a regular file or a folder.
Index ¶
- type Driver
- func (d *Driver) Delete(ctx context.Context, m mounts.Mount, ts oauth2.TokenSource, ...) (*mounts.WriteResult, error)
- func (d *Driver) FetchAt(ctx context.Context, m mounts.Mount, ts oauth2.TokenSource, version string, ...) (blobs.Hash, bool, error)
- func (d *Driver) HostPath(m mounts.Mount, p string) (string, error)
- func (d *Driver) Kind() mounts.Kind
- func (d *Driver) ListAt(ctx context.Context, m mounts.Mount, ts oauth2.TokenSource, ...) ([]mounts.File, error)
- func (d *Driver) Modes() []mounts.Mode
- func (d *Driver) Moves(ctx context.Context, source, ref string, ts oauth2.TokenSource) (bool, error)
- func (d *Driver) Open(ctx context.Context, m mounts.Mount, ts oauth2.TokenSource) (fs.FS, error)
- func (d *Driver) Put(ctx context.Context, m mounts.Mount, ts oauth2.TokenSource, ...) (*mounts.WriteResult, error)
- func (d *Driver) Resolve(ctx context.Context, source, ref string, ts oauth2.TokenSource) (string, error)
- func (d *Driver) Stat(ctx context.Context, m mounts.Mount, ts oauth2.TokenSource, p string) (mounts.FileVersion, error)
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver serves mounts.KindFolder mounts, whose Source is the folder's absolute path. It implements mounts.Writer, mounts.Localizer and mounts.VersionReader. It ignores token sources.
A write's IfMatch check and the write itself happen under a lock per file held in this Driver, so two writers in one process can't both pass the check. Writers in two processes, or two Drivers, can. Share one Driver per process.
func (*Driver) Delete ¶
func (d *Driver) Delete(ctx context.Context, m mounts.Mount, ts oauth2.TokenSource, req mounts.DeleteRequest) (*mounts.WriteResult, error)
Delete removes req.Path when IfMatch is its current version or AnyVersion. Empty IfMatch never matches an existing file, so it returns ErrConflict. A missing file returns ErrNotFound. Delete leaves empty parent folders in place.
func (*Driver) FetchAt ¶ added in v0.7.14
func (d *Driver) FetchAt(ctx context.Context, m mounts.Mount, ts oauth2.TokenSource, version string, f mounts.File) (blobs.Hash, bool, error)
FetchAt reads f from the folder and keeps it in the driver's blob store. fetched is true when the store didn't hold the contents yet.
func (*Driver) HostPath ¶
HostPath returns the absolute path of p in the folder. The file need not exist, so a native tool can write its output there. A path through a link returns ErrInvalidPath.
func (*Driver) ListAt ¶ added in v0.7.14
func (d *Driver) ListAt(ctx context.Context, m mounts.Mount, ts oauth2.TokenSource, version, under string) ([]mounts.File, error)
ListAt walks the folder at under as it is now, or returns the one file under names. A folder has no versions, so any version but "" returns ErrInvalidArgument. Links and anything else that isn't a regular file are left out, and a path through a link returns ErrInvalidPath.
func (*Driver) Modes ¶
Modes returns mounts.ModeLive. A folder mount always shows the folder as it is now.
func (*Driver) Moves ¶ added in v0.7.14
func (d *Driver) Moves(ctx context.Context, source, ref string, ts oauth2.TokenSource) (bool, error)
Moves returns true. A folder has no history, so a sync always reads it as it is now.
func (*Driver) Open ¶
Open returns the folder's files as they are now. The fs.FS refuses a path through a link with an error wrapping ErrInvalidPath, and its listings leave links out, so fs.WalkDir sees only regular files and folders.
func (*Driver) Put ¶
func (d *Driver) Put(ctx context.Context, m mounts.Mount, ts oauth2.TokenSource, req mounts.PutRequest) (*mounts.WriteResult, error)
Put writes req.Data to req.Path through a temp file and a rename, so a reader sees the old file or the new one and never part of either. It creates missing parent folders. The IfMatch check follows mounts.PutRequest. The result's Mount version is empty, since a folder has none.
func (*Driver) Resolve ¶
func (d *Driver) Resolve(ctx context.Context, source, ref string, ts oauth2.TokenSource) (string, error)
Resolve checks that source is an absolute path to a folder, and returns an empty version. A folder has no refs, so a non-empty ref returns ErrInvalidArgument, as does a relative path or a file. A missing folder returns ErrNotFound.
func (*Driver) Stat ¶
func (d *Driver) Stat(ctx context.Context, m mounts.Mount, ts oauth2.TokenSource, p string) (mounts.FileVersion, error)
Stat returns the file's version, "sha256:" and the hex SHA-256 of its contents. Content hashes, unlike modification times, don't change when nothing did, and can't collide when a file changes twice in one clock tick.
type Option ¶ added in v0.7.14
type Option func(*Driver)
Option configures a Driver.
func WithBlobs ¶ added in v0.7.14
WithBlobs sets the blob store FetchAt keeps files in. Without it, FetchAt returns ErrInvalidArgument.
func WithLinksInside ¶ added in v0.7.15
func WithLinksInside() Option
WithLinksInside lets reads follow a link whose target stays inside the mount's folder: listings, Open, HostPath, ListAt and FetchAt. A link that leads outside, directly or through another link, is still refused with ErrInvalidPath and left out of listings. Writes never go through a link. Without it, every link is refused, which is the default.