Documentation
¶
Overview ¶
Package mounts names the places an app's files live. A mount is a folder or a GitHub repo, and later an S3 or GCS bucket. Each is reached by a name, and a file in it by a mount:// URI. An app keeps its own records in its own store, and those records point into mounts by URI.
This package holds the contract: the Mount record, the URI and name rules, the interfaces a driver and a record store implement, and the errors they return. The design, with how agni and notation use it, is at https://panyam.github.io/goapplib/reference/mounts/.
Index ¶
- Constants
- Variables
- func CleanPath(p string) (string, error)
- func ValidName(name string) error
- type Change
- type DeleteRequest
- type Driver
- type File
- type FileVersion
- type Kind
- type Limits
- type ListRefsRequest
- type Localizer
- type Mode
- type Mount
- type Option
- type Preparer
- type PutRequest
- type RecordStore
- type Ref
- type RefKind
- type RefLister
- type RefPage
- type Registry
- func (r *Registry) BlobRefs(store blobs.Store) blobs.Referrer
- func (r *Registry) Create(ctx context.Context, m Mount) (Mount, error)
- func (r *Registry) Delete(ctx context.Context, name string) error
- func (r *Registry) DeleteWebhook(ctx context.Context, name, url string) error
- func (r *Registry) EnsureWebhook(ctx context.Context, name string, req WebhookRequest) (Webhook, error)
- func (r *Registry) FS(ctx context.Context) fs.FS
- func (r *Registry) FetchAt(ctx context.Context, name, version string, f File) (blobs.Hash, bool, error)
- func (r *Registry) Following(ctx context.Context, kind Kind, c Change) ([]Mount, error)
- func (r *Registry) Get(ctx context.Context, name string) (Mount, error)
- func (r *Registry) HostPath(ctx context.Context, u URI) (string, error)
- func (r *Registry) List(ctx context.Context) ([]Mount, error)
- func (r *Registry) ListAt(ctx context.Context, name, version, under string) ([]File, error)
- func (r *Registry) ListRefs(ctx context.Context, name string, req ListRefsRequest) (RefPage, error)
- func (r *Registry) Open(ctx context.Context, u URI) (fs.File, error)
- func (r *Registry) Put(ctx context.Context, name string, req PutRequest) (*WriteResult, error)
- func (r *Registry) Remove(ctx context.Context, name string, req DeleteRequest) (*WriteResult, error)
- func (r *Registry) ResolveAt(ctx context.Context, name, ref string) (version string, moves bool, err error)
- func (r *Registry) Stat(ctx context.Context, u URI) (FileVersion, error)
- type SourceMatcher
- type URI
- type VersionReader
- type Webhook
- type WebhookManager
- type WebhookRequest
- type WriteResult
- type Writer
Constants ¶
const Scheme = "mount://"
Scheme is the URI scheme for a file in a mount.
Variables ¶
var ( // ErrNotFound means no mount has that name, or no file has that path in the mount, or the // source (a repo, a ref) doesn't exist upstream. ErrNotFound = errors.New("mounts: not found") // ErrExists means a mount with that name exists already, fixed or runtime. ErrExists = errors.New("mounts: already exists") // ErrInvalidArgument means a name, a source or a ref is malformed, or a request asked for // something the driver doesn't do, such as a mode it doesn't support. ErrInvalidArgument = errors.New("mounts: invalid argument") // ErrInvalidPath means a path is absolute, climbs out of its mount, or names a link. ErrInvalidPath = errors.New("mounts: invalid path") // ErrFixed means the request would change a mount that comes from the server's // configuration, which only a restart with new configuration changes. ErrFixed = errors.New("mounts: mount is fixed") // ErrTooLarge means a snapshot or a write would pass a Limits cap. ErrTooLarge = errors.New("mounts: over the size or file-count limit") // rate limit. Retrying later may work. ErrUnavailable = errors.New("mounts: source unavailable") // ErrConflict means a write's IfMatch didn't match the file's current version, because // someone else changed or created it first. Read it again and retry. ErrConflict = errors.New("mounts: version conflict") // ErrReadOnly means the mount can't be written: it is a snapshot, or its driver has no // Writer. ErrReadOnly = errors.New("mounts: mount is read-only") // ErrNotLocal means the mount has no folder on this server's disk, so it has no host path. ErrNotLocal = errors.New("mounts: no host path") // ErrInUse means the app's in-use check says records still point into the mount, so it // can't be deleted. ErrInUse = errors.New("mounts: mount is in use") // ErrPermissionDenied means the source refused the mount's token for this request, though // the token may read the source. A GitHub token needs admin rights on a repo, or a // fine-grained token's webhooks permission, to manage its hooks. ErrPermissionDenied = errors.New("mounts: permission denied") )
The errors a driver, a record store and the registry return, wrapped with detail. An app maps them onto its own transport with errors.Is. The mounts design page has the table agni uses.
var DefaultLimits = Limits{MaxBytes: 256 << 20, MaxFiles: 100_000}
DefaultLimits are agni's caps for a GitHub snapshot: 256 MB and 100,000 files.
Functions ¶
func CleanPath ¶
CleanPath applies NewURI's path rules to p, a path inside a mount. It returns the clean, relative, slash-separated form, and "" for the mount's root. An absolute path, or one that climbs out with "..", wraps ErrInvalidPath. Drivers call it on every path they are given, so a path that skipped NewURI still can't leave the mount.
func ValidName ¶
ValidName reports whether name can name a mount. A name is 1 to 64 characters. The first is a-z or 0-9, and the rest may also be '-', '_' or '.'. The rule keeps names safe as a folder name, a URL path element and a YAML file name on any OS. It returns an error wrapping ErrInvalidArgument.
Types ¶
type Change ¶ added in v0.7.16
type Change struct {
// Source is the source that changed, in the driver's form, such as "github://owner/repo".
Source string
// Ref is the short name of the ref that moved, such as "main" or "v1.2.0".
Ref string
// RefKind is RefBranch or RefTag.
RefKind RefKind
// Version is what Ref points at now, in the format the driver's Resolve returns. It is empty
// when Deleted is true.
Version string
// Before is what Ref pointed at before, empty when the ref is new.
Before string
// Deleted is true when the ref was removed.
Deleted bool
// Default is true when Ref is the source's default branch, so a mount whose Ref is empty
// follows it.
Default bool
}
Change says that a ref in a source moved, such as a push to a branch that a host's webhook reported (goapplib issue 179). A driver's package turns its host's event into a Change, as github.ParsePush does, so an app's handler finds the mounts to check with Registry.Following and never reads the host's own format.
type DeleteRequest ¶
type DeleteRequest struct {
Path string
IfMatch FileVersion
Message string
}
DeleteRequest removes Path. IfMatch must be the file's current version, or AnyVersion.
type Driver ¶
type Driver interface {
// Kind is the Kind of mount this driver serves.
Kind() Kind
// Modes lists the modes the driver supports. A request for any other returns
// ErrInvalidArgument.
Modes() []Mode
// Resolve checks source and turns ref into a version: a commit for GitHub, an empty string
// for a folder. An empty ref means the source's default, such as the default branch. A
// source or ref that doesn't exist returns ErrNotFound.
Resolve(ctx context.Context, source, ref string, ts oauth2.TokenSource) (version string, err error)
// Open returns the mount's files. For a snapshot mount they are the files at m.Version, and
// the same call returns the same bytes for the life of the mount. For a live mount they are
// the source's latest. Paths in the fs.FS are clean, relative and slash-separated, so a
// URI's Path opens directly. Only regular files and folders appear in it, never links.
Open(ctx context.Context, m Mount, ts oauth2.TokenSource) (fs.FS, error)
}
Driver reads one Kind of source. The registry calls it with the token source of the mount's connection, or nil for a public or local source. A driver doesn't know about connections or viewers. It sends the token it is given.
type File ¶ added in v0.7.14
File is one file a VersionReader lists. Path is relative to the mount's root, clean and slash-separated. ID is the source's own name for the contents, such as a git blob id, and is empty when the source has none. Size is in bytes.
type FileVersion ¶
type FileVersion string
FileVersion identifies one version of one file, in the driver's own format.
const AnyVersion FileVersion = "*"
AnyVersion as IfMatch lets a write replace whatever version is there, or create the file.
type Kind ¶
type Kind string
Kind says which driver serves a mount.
const ( // KindFolder is a folder on the server's disk. Folder mounts come from the server's own // configuration, never from a request, since a client may not pick a server folder. KindFolder Kind = "folder" // KindGitHub is a GitHub repository, read through GitHub's REST API. KindGitHub Kind = "github" )
type Limits ¶
Limits caps what a snapshot or a write may hold. A driver returns ErrTooLarge past either. Zero means the default.
type ListRefsRequest ¶ added in v0.7.16
ListRefsRequest picks what ListRefs lists. Kind is RefTag or RefCommit. For RefCommit, Branch names the branch, and empty means the source's default. PageSize is a hint the driver may cap, and zero means the driver's default. PageToken is the NextPageToken of the page before, or empty for the first page.
type Localizer ¶
type Localizer interface {
Driver
// HostPath returns the host path of p inside m. It returns ErrNotLocal when m has no
// folder here, and ErrInvalidPath when p would leave the mount.
HostPath(m Mount, p string) (string, error)
}
Localizer is a Driver whose mounts can have a folder on this server's disk, for code that needs a host path, such as a native tool. A snapshot driver's view counts too.
type Mode ¶
type Mode string
Mode says whether a mount's files can change after it is made.
const ( // ModeSnapshot pins the mount at the version its ref resolved to when it was made. Its files // never change, so a record that points into it keeps meaning the same bytes. agni uses this // for designs. ModeSnapshot Mode = "snapshot" // ModeLive reads the source's latest version on each open, and a Writer can change it. // notation uses this for notations it edits. ModeLive Mode = "live" )
type Mount ¶
type Mount struct {
// Name is the mount's handle in URIs: mount://<Name>/<path>. ValidName gives the rule.
Name string
Kind Kind
// Source says where the files come from, in the driver's own form: "github://owner/repo"
// for GitHub, or an absolute path for a folder.
Source string
// Ref is what the mount was asked for, such as a branch, a tag or a commit. Empty means the
// source's default.
Ref string
// Version is what Ref resolved to when the mount was made, such as a commit sha. The driver
// defines its format. For a snapshot mount the files are those at Version. A live mount has
// moved on since, and its Writer returns each new version.
Version string
Mode Mode
// Connection is the ID of the connection the driver reads through (package connections).
// Empty means the source is public, or local.
Connection string
// Manifest is the hash of the blob listing a snapshot's files and their hashes, which is
// what rebuilds a snapshot's view after a restart. It is empty for a live mount.
Manifest string
Created time.Time
}
Mount is the library's record of one mount. An app keeps any fields of its own in its own records, keyed by Name.
type Option ¶
type Option func(*Registry)
Option configures a Registry.
func WithCredentials ¶
func WithCredentials(f func(ctx context.Context, connection string) (oauth2.TokenSource, error)) Option
WithCredentials sets how the registry gets a mount's token source from its Connection ID. The connections service's TokenSource method has this signature. It is called with the request's context, so a connection that belongs to one person sees who is asking. A mount with an empty Connection gets a nil token source without a call.
func WithFixed ¶
WithFixed adds mounts from the server's configuration, such as agni's --mount flags. They can't be deleted, and a runtime record with the same name is ignored. They are the only way to get a KindFolder mount.
func WithInUse ¶
WithInUse sets the app's check for whether its records still point into a mount. Delete calls it, and returns ErrInUse when it says true.
func WithLimits ¶
WithLimits caps writes through the registry. A zero field keeps DefaultLimits' value. Drivers that snapshot take their own Limits.
func WithRecheck ¶
WithRecheck sets how often the registry asks the store whether another process changed it. The default is a second. Tests set it lower.
type Preparer ¶
type Preparer interface {
Driver
Prepare(ctx context.Context, m Mount, ts oauth2.TokenSource) (Mount, error)
}
Preparer is a Driver with work to do when a mount is made, after Resolve. A GitHub snapshot downloads the commit's files into the blob store there, and sets the mount's Manifest. The registry stores the Mount that Prepare returns. A Prepare error fails the Create, and no record is written.
type PutRequest ¶
type PutRequest struct {
Path string
Data []byte
IfMatch FileVersion
// Message is the commit message, for drivers that commit. Others ignore it.
Message string
}
PutRequest writes Data to Path. IfMatch guards against overwriting a change the caller hasn't seen. Empty means the file must not exist yet. AnyVersion means write regardless. Anything else must equal the file's current version. A mismatch returns ErrConflict.
type RecordStore ¶
type RecordStore interface {
// ListMounts returns every record, in name order.
ListMounts(ctx context.Context) ([]Mount, error)
// GetMount returns the record named name, or ErrNotFound.
GetMount(ctx context.Context, name string) (Mount, error)
// CreateMount adds m. A record with m.Name returns ErrExists, so of two processes creating
// the same name, one wins.
CreateMount(ctx context.Context, m Mount) error
// DeleteMount removes the record named name. Deleting a missing record is not an error.
DeleteMount(ctx context.Context, name string) error
// Generation returns a value that changes whenever any process creates or deletes a record.
// The registry compares it with the last one it read, and lists again only when they differ.
// The format is the store's own.
Generation(ctx context.Context) (string, error)
}
RecordStore keeps the runtime mounts, the ones made by requests rather than by the server's configuration. Records are created and deleted, never changed in place. A live mount's latest version comes from its driver, not from its record.
Several processes may share one store, such as a server and a worker. Each notices the others' changes through Generation.
type Ref ¶ added in v0.7.16
Ref is one tag or commit. Name is what a mount's Ref field takes to pin it: the tag's name, or the commit's id. Version is the commit Name resolves to, in the format Resolve returns, so an app can pass it to ListAt without resolving it again. Time is the commit's date. Message is the first line of the commit's message, and may be empty, as it is for a tag on some hosts.
type RefLister ¶ added in v0.7.16
type RefLister interface {
Driver
// ListRefs lists source's tags, newest first by their commit's date, or the commits on one
// branch, newest first. A source or branch that doesn't exist returns ErrNotFound. A request
// the driver can't serve, such as tags with no token on a host that needs one, returns
// ErrInvalidArgument.
ListRefs(ctx context.Context, source string, req ListRefsRequest, ts oauth2.TokenSource) (RefPage, error)
}
RefLister is a Driver that lists the versions its sources have, so an app can offer a list of revisions to link to (goapplib issue 177). agni lists a linked design's tags and a branch's commits with it. A driver whose sources have no history implements it and returns an empty page.
type RefPage ¶ added in v0.7.16
RefPage is one page of refs. An empty NextPageToken means it is the last page.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is an app's one view of its mounts. It joins the fixed mounts from the server's configuration, the runtime mounts in a RecordStore, and the drivers that read them, and it asks for each mount's credentials when a driver needs them.
Several registries, in one process or several, can share a RecordStore. Each checks the store's Generation at most once per recheck interval (a second by default), and lists the store again only when it changed. A registry sees its own creates and deletes at once.
A Registry is safe for concurrent use.
func NewRegistry ¶
func NewRegistry(store RecordStore, drivers []Driver, opts ...Option) *Registry
NewRegistry returns a registry over store, serving the kinds of drivers. Two drivers of one kind keep the later one. A nil store serves the fixed mounts alone, for an app with no store of its own, such as agni's CLI. Create and Delete then return ErrInvalidArgument.
func (*Registry) BlobRefs ¶
BlobRefs returns a blobs.Referrer that names, for every snapshot mount, its manifest and every file the manifest lists, so a sweep of store keeps them. Pass it to store's Sweep beside the app's own referrers. A manifest that can't be read fails the referrer, and so the sweep, rather than letting the sweep remove a snapshot's files. The registry rereads its records at most once per recheck interval, so a sweep's grace period should be longer than that.
func (*Registry) Create ¶
Create makes a runtime mount from m's Name, Kind, Source, Ref, Mode and Connection. An empty Mode takes the driver's first. Create resolves Ref through the driver, calls Prepare when the driver has it, sets Version and Created, and writes the record. It returns ErrInvalidArgument for a bad name, an unknown kind, a mode the driver doesn't serve, or KindFolder. A name taken by a fixed or runtime mount returns ErrExists. Driver errors pass through, such as ErrNotFound for a source that doesn't exist.
func (*Registry) Delete ¶
Delete removes the runtime mount named name. A fixed mount returns ErrFixed, a missing one ErrNotFound, and one the in-use check says is still referenced ErrInUse. Delete removes only the record. Blobs a snapshot used stay until a blob sweep finds nothing naming them.
func (*Registry) DeleteWebhook ¶ added in v0.7.18
DeleteWebhook removes the hooks that send the source's changes of the mount named name to url, through the mount's connection. No such hook is not an error. It returns ErrInvalidArgument in the cases EnsureWebhook does, apart from the secret.
func (*Registry) EnsureWebhook ¶ added in v0.7.18
func (r *Registry) EnsureWebhook(ctx context.Context, name string, req WebhookRequest) (Webhook, error)
EnsureWebhook makes or updates the hook that sends the source's changes of the mount named name to req.URL, through the mount's connection. It returns ErrInvalidArgument for a URL that isn't absolute http or https, an empty secret, a mount with no connection (a source doesn't let an anonymous caller manage hooks), or a kind whose driver has no WebhookManager.
func (*Registry) FS ¶
FS returns every mount as one fs.FS, each under its name, through goutils' mountfs. It lists the mounts once, when called, and opens each mount's driver when a path first reaches it. The context is kept for those opens, so the viewer it carries is the one whose connections are used. An app calls FS per request, or per job with that job's context.
func (*Registry) FetchAt ¶ added in v0.7.14
func (r *Registry) FetchAt(ctx context.Context, name, version string, f File) (blobs.Hash, bool, error)
FetchAt keeps f's contents at version, in the mount named name, in the driver's blob store.
func (*Registry) Following ¶ added in v0.7.16
Following returns the mounts of kind whose source is c.Source and whose ref is c.Ref, or empty when c is a change to the default branch. Snapshot and live mounts both match, since an app may want to move a snapshot's links forward. A mount pinned to a commit never matches. A kind with no driver returns ErrInvalidArgument.
func (*Registry) HostPath ¶
HostPath returns the host path of the file u names, for code that needs a real file. A mount whose driver isn't a Localizer returns ErrNotLocal.
func (*Registry) List ¶
List returns every mount, fixed and runtime, in name order. When the store fails after a good read, List keeps returning the last good list rather than dropping every runtime mount.
func (*Registry) ListAt ¶ added in v0.7.14
ListAt lists the files at version under the path under, in the mount named name.
func (*Registry) ListRefs ¶ added in v0.7.16
ListRefs lists the tags, or a branch's commits, of the source of the mount named name, through its connection. A driver that can't list refs returns ErrInvalidArgument, and a Kind other than RefTag or RefCommit does too.
func (*Registry) Put ¶
func (r *Registry) Put(ctx context.Context, name string, req PutRequest) (*WriteResult, error)
Put writes a file in the mount named name, with req.Path cleaned by CleanPath. A snapshot mount, or one whose driver isn't a Writer, returns ErrReadOnly. Data over the registry's MaxBytes returns ErrTooLarge. The IfMatch rules are mounts.PutRequest's.
func (*Registry) Remove ¶
func (r *Registry) Remove(ctx context.Context, name string, req DeleteRequest) (*WriteResult, error)
Remove deletes a file in the mount named name, under the same rules as Put.
func (*Registry) ResolveAt ¶ added in v0.7.14
func (r *Registry) ResolveAt(ctx context.Context, name, ref string) (version string, moves bool, err error)
ResolveAt resolves ref against the source of the mount named name, through its connection. It returns the version, empty for a source with no history, and whether ref moves.
type SourceMatcher ¶ added in v0.7.16
type SourceMatcher interface {
Driver
// SameSource reports whether a and b name the same source.
SameSource(a, b string) bool
}
SourceMatcher is a Driver that says when two of its sources name the same place, when plain string equality isn't enough. GitHub's owner and repo names ignore case, for one.
type URI ¶
URI names a file or folder in a mount: mount://<Mount>/<Path>. Path is clean and relative, and never leaves the mount, so resolving it against the mount's root can't reach a file outside it. The empty Path is the mount's root.
func NewURI ¶
NewURI builds a URI from a mount name and a path inside it. The path may use '\' as a separator and may end in '/'. It may not be absolute or climb out with "..". Both failures wrap ErrInvalidPath, and a bad name wraps ErrInvalidArgument.
A URI's mount name follows a looser rule than ValidName: any name that isn't empty, ".", "..", and holds no '/' or '\'. An app names a fixed mount after a folder, such as agni's --mount-root, and a folder can have capitals or spaces. ValidName still governs the runtime mounts a record store keeps.
func ParseURI ¶
ParseURI parses "mount://<name>/<path>" with the rules of NewURI. Any other scheme wraps ErrInvalidPath.
func (URI) Base ¶ added in v0.7.15
Base returns the last element of the path, as path.Base does, and "" for the mount's root.
func (URI) Dir ¶ added in v0.7.15
Dir returns the URI of the folder holding u, or u itself for the mount's root.
func (URI) IsZero ¶ added in v0.7.15
IsZero reports whether the URI names nothing, as an absent optional field does.
func (URI) Resolve ¶ added in v0.7.15
Resolve reads ref relative to u, the way a browser reads an href against the page it is on. A reader uses it when a file names another, such as a schematic naming its child sheets.
A full mount:// URI replaces u, mount included. "/x" names x from the mount's root. Anything else resolves against u's folder, so "sub/a.kicad_sch" against mount://m/designs/top.kicad_sch is mount://m/designs/sub/a.kicad_sch. A result that would climb out of the mount wraps ErrInvalidPath. Unlike RFC 3986, a leading ".." on an absolute path is an error rather than dropped, since quietly reading "/../x" as "/x" would hide a traversal attempt.
type VersionReader ¶ added in v0.7.14
type VersionReader interface {
Driver
// Moves reports whether ref names something that moves, so a later sync should follow it: an
// empty ref, a branch, or any ref of a source with no history. A tag or a commit doesn't move.
Moves(ctx context.Context, source, ref string, ts oauth2.TokenSource) (bool, error)
// ListAt returns the regular files at version that are at or under the path under, sorted by
// path. An empty under is the mount's root. It leaves out links, submodules and anything else
// that isn't a regular file, and returns none for a path that names nothing. Past the
// driver's Limits it returns ErrTooLarge. version is what Resolve returned, empty for a source
// with no history.
ListAt(ctx context.Context, m Mount, ts oauth2.TokenSource, version, under string) ([]File, error)
// FetchAt puts f's contents at version in the driver's blob store and returns their hash.
// fetched is false when the store already held them and nothing was downloaded. A download
// that doesn't match f.ID returns ErrUnavailable and keeps nothing.
FetchAt(ctx context.Context, m Mount, ts oauth2.TokenSource, version string, f File) (h blobs.Hash, fetched bool, err error)
}
VersionReader is a Driver that reads a mount's source at any version, not only the one a snapshot mount pins (goapplib issue 172). An app links a record to a file at a commit with it, and later moves the link to a newer commit, downloading only the files that changed. agni's linked artifacts are the first user.
type Webhook ¶ added in v0.7.18
Webhook is a hook as the source holds it. ID is the source's id for it. Created is true when EnsureWebhook made it, and false when it updated a hook already sending to URL.
type WebhookManager ¶ added in v0.7.18
type WebhookManager interface {
Driver
// EnsureWebhook makes a hook on source that sends req.Events to req.URL, signed with
// req.Secret, or updates the hook already sending to req.URL. A token that can't manage the
// source's hooks returns ErrPermissionDenied, and a request the source refuses, such as a URL
// it won't send to, returns ErrInvalidArgument.
EnsureWebhook(ctx context.Context, source string, req WebhookRequest, ts oauth2.TokenSource) (Webhook, error)
// DeleteWebhook removes the hooks on source that send to url. No such hook is not an error,
// so deleting twice is safe. A token that can't manage the source's hooks returns
// ErrPermissionDenied.
DeleteWebhook(ctx context.Context, source, url string, ts oauth2.TokenSource) error
}
WebhookManager is a Driver that can make a source send a webhook to the app on each change, so the app syncs a mount when its branch moves rather than polling it (goapplib issue 185). A hook is named by the URL it sends to, so making one twice updates the first rather than adding a second.
type WebhookRequest ¶ added in v0.7.18
WebhookRequest describes a hook. URL is where the source sends each delivery, and must be an absolute http or https URL. Secret signs each delivery, and must not be empty, since the app can't verify an unsigned one. Events names the source's events, and empty means "push".
type WriteResult ¶
type WriteResult struct {
// File is the file's new version. It is empty after a Delete.
File FileVersion
// Mount is the mount's new version, such as the commit a GitHub write made. Drivers whose
// sources have no version across files leave it empty.
Mount string
}
WriteResult is what a write produced.
type Writer ¶
type Writer interface {
Driver
// Stat returns the current version of the file at p, which a later Put or Delete passes as
// IfMatch. For GitHub it is the file's blob sha. A missing file returns ErrNotFound.
Stat(ctx context.Context, m Mount, ts oauth2.TokenSource, p string) (FileVersion, error)
// Put creates or replaces the file at req.Path. A GitHub Put is one commit.
Put(ctx context.Context, m Mount, ts oauth2.TokenSource, req PutRequest) (*WriteResult, error)
// Delete removes the file at req.Path. A GitHub Delete is one commit.
Delete(ctx context.Context, m Mount, ts oauth2.TokenSource, req DeleteRequest) (*WriteResult, error)
}
Writer is a Driver that can change a live mount. A write to a snapshot mount returns ErrReadOnly before reaching the driver.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package folder is the mounts driver for a folder on the server's disk.
|
Package folder is the mounts driver for a folder on the server's disk. |
|
Package fsstore keeps mount records in a folder, one YAML file per mount, named <name>.yaml.
|
Package fsstore keeps mount records in a folder, one YAML file per mount, named <name>.yaml. |
|
Package github is the mounts driver for GitHub repositories, read and written through GitHub's REST API.
|
Package github is the mounts driver for GitHub repositories, read and written through GitHub's REST API. |
|
githubtest
Package githubtest is a fake GitHub for tests of code that reads and writes repos: the mounts GitHub driver, the storage example app, and consumers' own tests.
|
Package githubtest is a fake GitHub for tests of code that reads and writes repos: the mounts GitHub driver, the storage example app, and consumers' own tests. |
|
Package mountstest checks that a mounts.RecordStore keeps the contract the registry relies on.
|
Package mountstest checks that a mounts.RecordStore keeps the contract the registry relies on. |