Documentation
¶
Overview ¶
Package nfsserver serves knot's file storage over NFSv4.0 and NFSv3, so buckets can be mounted by the operating system (the macOS Finder or mount_nfs) and by Docker and Podman as volumes with the local driver's nfs type, without FUSE. It is a client of a knot server's files API, acting as the user whose token it is given, so any number can run against one knot server.
NFS itself carries no authentication, so the server only accepts connections from the addresses it is told to trust: loopback by default.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
Buckets(ctx context.Context) ([]Bucket, error)
Bucket(ctx context.Context, name string) (*Bucket, error)
CreateBucket(ctx context.Context, name string) error
DeleteBucket(ctx context.Context, name string) error
Head(ctx context.Context, bucket, key string) (*Object, error)
// Stat says what a path is in one request: a file, or a folder, with
// its marker (the object keeping an empty folder) when it has one. A
// path that is neither is os.ErrNotExist.
Stat(ctx context.Context, bucket, key string) (*Stat, error)
// List lists a folder; with a delimiter, Listing.Markers holds the
// markers of the folders rolled up into Prefixes.
List(ctx context.Context, bucket, prefix, delimiter, after string, max int) (*Listing, error)
// ReadAt reads part of a file, returning io.EOF with what there is at
// its end.
ReadAt(ctx context.Context, bucket, key string, p []byte, off int64) (int, error)
// Get reads a whole file.
Get(ctx context.Context, bucket, key string) (io.ReadCloser, *Object, error)
Put(ctx context.Context, bucket, key string, r io.Reader, size int64, contentType string, meta map[string]string) (*Object, error)
// Patch changes part of a file, sending only the ranges: they are
// written over it, in order and not overlapping, and it is cut or
// zero-filled to size. With ifMatch, only if it still has that ETag.
Patch(ctx context.Context, bucket, key string, ranges []Range, size int64, ifMatch, contentType string, meta map[string]string) (*Object, error)
Delete(ctx context.Context, bucket, key string) error
// SetMeta replaces a file's metadata, if it still has the ETag ifMatch.
SetMeta(ctx context.Context, bucket, key string, meta map[string]string, ifMatch string) error
// Move renames a file, or a folder and everything under it, replacing
// what is at the destination.
Move(ctx context.Context, bucket, from, to string) error
// Forget drops anything kept of a file changed elsewhere; an empty key
// means every file in the bucket, and an empty bucket every bucket.
Forget(bucket, key string)
}
Backend is the file storage the filesystem serves. Errors are matched with errors.Is against os.ErrNotExist, os.ErrExist, os.ErrPermission, syscall.ENOTEMPTY, syscall.EDQUOT, syscall.EINVAL and errPrecondition.
Buckets are named as the user sees them: the short name for their own, the full name for those shared with them.
func NewAPIBackend ¶
NewAPIBackend serves file storage through client.
type Config ¶
type Config struct {
Listen string // address to listen on, e.g. 127.0.0.1:2049
Allow []string // client addresses or CIDRs allowed to connect; loopback when empty
FlushDelay time.Duration // save a written file once writes stop for this long
MaxDirtyAge time.Duration // and at the latest this long after it changed
StagingDir string // where written files wait to be saved; a temp dir when empty
Uid, Gid uint32 // owner of files with none stored
// ForceUid and ForceGid make Uid and Gid the owner of every file,
// whatever owner is stored, so files look the mounting user's own
// (a container's root, say). An owner set is still stored.
ForceUid, ForceGid bool
// CacheDir keeps files read and written on local disk, up to CacheSize
// bytes, so they need not be fetched again; none when empty.
CacheDir string
CacheSize int64
// Writer is the name this server's backend gives the changes it makes
// (apiclient.ApiClient.SetWriter), so it can pass over its own.
Writer string
}
type FileChanged ¶
type FileChanged struct {
BucketId, Key, Writer string
}
FileChanged is a file named in a change event, and the writer that changed it, when it said.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) Changed ¶
func (s *Server) Changed(bucketIds []string, files []FileChanged)
Changed tells of changes to the buckets with these ids, made through this server or anywhere else, naming the files where it can; no buckets means any bucket.