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) HostPath(m mounts.Mount, p string) (string, error)
- func (d *Driver) Kind() mounts.Kind
- func (d *Driver) Modes() []mounts.Mode
- 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)
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 and mounts.Localizer. 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) 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) Modes ¶
Modes returns mounts.ModeLive. A folder mount always shows the folder 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.