Documentation
¶
Overview ¶
Package vpath is a helper package easing the expansion of a virtual path like vol1/etc/nginx.conf to a host path like /srv/svc1data.ns1.vol.clu1/etc/nginx.conf
A path is written in one of three forms:
/etc/nginx.conf a path of the node
vol1/etc/nginx.conf a path in the vol object vol1, of the namespace
volume#1:/etc/nginx.conf a path in a resource of the object: a volume,
or a filesystem, under its mount point
A vol name is a hostname, which holds no '#', so a reference before the ':' holding one is a resource id, and the forms never mean one another.
Index ¶
- func Devpath(ctx context.Context, from, s, namespace string, resolver Resolver) (string, error)
- func Devpaths(ctx context.Context, from, s, namespace string, resolver Resolver) ([]string, error)
- func DevpathsOf(ctx context.Context, from string, elements []string, namespace string, ...) ([]string, error)
- func HostDevpath(ctx context.Context, s string, namespace string) (string, error)
- func HostDevpaths(ctx context.Context, l []string, namespace string) ([]string, error)
- func HostPath(ctx context.Context, s string, namespace string) (string, error)
- func HostPathAndVol(ctx context.Context, s string, namespace string) (hostPath string, vol object.Vol, err error)
- func HostPaths(ctx context.Context, l []string, namespace string) ([]string, error)
- func IsResourceRef(s string) bool
- func ResolveHostPath(ctx context.Context, s string, namespace string, resolver Resolver) (string, error)
- type ErrAccess
- type Resolver
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Devpath ¶
Devpath returns the device of the node one element of a device keyword names, as Devpaths does, for a keyword naming a single device: a resource id must name a resource exposing one.
func Devpaths ¶
Devpaths returns the devices of the node one element of a device keyword names:
/dev/sdb a device of the node
/srv/f.img a loop file, the device it is attached to
data a vol of the namespace, the device it exposes
disk#1 a resource of the object, the devices it exposes, as a disk
or a volume does
from is the id of the resource whose keyword is resolved, which a resource id may not name, directly or through the devices of the resources it names. A resource exposing no device, as one that is not started, is an ErrAccess, as a vol that is not available is.
func DevpathsOf ¶
func DevpathsOf(ctx context.Context, from string, elements []string, namespace string, resolver Resolver) ([]string, error)
DevpathsOf returns the devices of the node the elements of a device list keyword name, as Devpaths does, in a new list.
func HostDevpath ¶
HostDevpath returns host device path for a volume translation rules: INPUT VOL OUTPUT COMMENT /path /dev/sda1 loop dev /dev/sda1 /dev/sda1 host full path myvol myvol /dev/sda1 vol dev path in host
func HostDevpaths ¶
HostDevpaths applies the HostDevpath function to each path of the input list, and returns the results in a new list: the input is often a keyword value, which must keep naming the vols rather than the devices they exposed once.
func HostPath ¶
HostPath expand a volume-relative path to a host full path.
Example:
INPUT VOL OUTPUT COMMENT /path /path host full path myvol/path myvol /srv/myvol/path vol head relative path
func HostPathAndVol ¶
func HostPathAndVol(ctx context.Context, s string, namespace string) (hostPath string, vol object.Vol, err error)
HostPathAndVol expand a volume-relative path to a host full path. It returns the host full path and the associated object volume if defined.
Example:
INPUT VOL host path COMMENT /path nil /path host full path myvol/path myvol /srv/myvol/path vol head relative path
func IsResourceRef ¶
IsResourceRef says whether the reference before the ':' of a path is the id of a resource of the object, as volume#1 in volume#1:/etc/nginx. A path of the node starts with a '/', and a vol name holds no '#'.
Types ¶
type ErrAccess ¶
ErrAccess is the error of a path in a vol or a resource that is not available here.
type Resolver ¶
Resolver finds the resources of the object a path is written in.
func ResolverOf ¶
ResolverOf returns the resolver of the resources of an object, nil when it has none.
type Target ¶
type Target struct {
// HostPath is the path on the node.
HostPath string
// Head is the mount point of the vol or the resource the path is
// in, and empty for a path of the node.
Head string
// Vol is the vol the path is in, nil for a path of the node, or of
// a resource that is no volume.
Vol object.Vol
}
Target is what a path resolves to.
func Locate ¶
Locate expands a path as Resolve does, whether the vol or the resource it is in is available here or not. It is for the path something was done to while it was, as an export to undo once the volume went down, and not for a path to read or write.
func Resolve ¶
Resolve expands a path to the path of the node it names, and says the mount point and the vol it is in.
A path in a resource of the object needs the resolver of the object, the resources being its own. The resource must hold a mount point, as a volume or a filesystem does, and be available here.