bind

package
v4.1.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option struct {
	Value string `json:"value,omitempty"`
}

Option represents a bind option with its associated value if any.

type Path

type Path struct {
	Source      string             `json:"source"`
	Destination string             `json:"destination"`
	Options     map[string]*Option `json:"options"`
}

Path stores a parsed bind path specification. Source and Destination paths are required.

func ParseBindPath

func ParseBindPath(bindpaths string) ([]Path, error)

ParseBindPath parses a string specifying one or more (comma separated) bind paths in src[:dst[:options]] format, and returns all encountered bind paths as a slice. Options may be simple flags, e.g. 'rw', or take a value, e.g. 'id=2'. Multiple options are separated with commas. Note that multiple binds are also separated with commas, so the logic must distinguish.

func ParseMountString

func ParseMountString(mount string) (bindPaths []Path, err error)

ParseMountString converts a --mount string into one or more BindPath structs.

Our intention is to support common docker --mount strings, but have additional fields for singularity specific concepts (image-src, id when binding out of an image file).

We use a CSV reader to parse the fields in a mount string according to CSV escaping rules. This is the approach docker uses to allow special characters in source / dest etc., and we wish to be as compatible as possible. It also allows us to handle multiple newline separated mounts, which is convenient for specifying multiple mounts in a single env var.

The fields are in key[=value] format. Flag options have no value, e.g.:

type=bind,source=/opt,destination=/other,rw

We only support type=bind at present, so assume this if type is missing and error for other types.

func (*Path) ID

func (b *Path) ID() string

ID returns the value of the option id for a BindPath, or an empty string if the option wasn't set.

func (*Path) ImageSrc

func (b *Path) ImageSrc() string

ImageSrc returns the value of the option image-src for a BindPath, or an empty string if the option wasn't set.

func (*Path) Readonly

func (b *Path) Readonly() bool

Readonly returns true if the ro option was set for a BindPath.

Jump to

Keyboard shortcuts

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