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 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 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
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 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.