vpath

package
v3.0.0-rc44 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func HostDevpath

func HostDevpath(ctx context.Context, s string, namespace string) (string, error)

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

func HostDevpaths(ctx context.Context, l []string, namespace string) ([]string, error)

HostDevpaths applies the HostDevpath function to each path of the input list

func HostPath

func HostPath(ctx context.Context, s string, namespace string) (string, error)

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 HostPaths

func HostPaths(ctx context.Context, l []string, namespace string) ([]string, error)

HostPaths applies the HostPath function to each path of the input list

func IsResourceRef

func IsResourceRef(s string) bool

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

func ResolveHostPath

func ResolveHostPath(ctx context.Context, s string, namespace string, resolver Resolver) (string, error)

ResolveHostPath expands a path, in any of its forms, to a path of the node.

Types

type ErrAccess

type ErrAccess struct {
	Path  naming.Path
	RID   string
	Avail status.T
}

ErrAccess is the error of a path in a vol or a resource that is not available here.

func (ErrAccess) Error

func (t ErrAccess) Error() string

type Resolver

type Resolver interface {
	ResourceByID(string) resource.Driver
}

Resolver finds the resources of the object a path is written in.

func ResolverOf

func ResolverOf(o any) Resolver

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

func Resolve(ctx context.Context, s string, namespace string, resolver Resolver) (Target, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL