storageutil

package
Version: v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2021 License: Apache-2.0 Imports: 20 Imported by: 3

Documentation

Index

Constants

View Source
const (
	StorageArgEnvRemotePath = "ARHAT_STORAGE_REMOTE_PATH"
	StorageArgEnvMountpoint = "ARHAT_STORAGE_MOUNTPOINT"
)

Variables

View Source
var (
	ErrMountpointInUse     = errors.New("already in use")
	ErrMountpointInProcess = errors.New("already in process")
)

Functions

func CleanupPodData

func CleanupPodData(podDir, remoteVolumeDir, tmpfsVolumeDir string, unmount func(path string) error) error

func FlagsForClient

func FlagsForClient(prefix string, config *ClientConfig) *pflag.FlagSet

func GenerateUnmountCmd

func GenerateUnmountCmd(binPath string, mountPoint string) []string

func IsLikelyNotMountPoint

func IsLikelyNotMountPoint(file string) (bool, error)

IsLikelyNotMountPoint determines if a directory is not a mountpoint. It is fast but not necessarily ALWAYS correct. If the path is in fact a bind mount from one part of a mount to another it will not be detected. It also can not distinguish between mountpoints and symbolic links. mkdir /tmp/a /tmp/b; mount --bind /tmp/a /tmp/b; IsLikelyNotMountPoint("/tmp/b") will return true. When in fact /tmp/b is a mount point. If this situation is of interest to you, don't use this function...

func LookupUnmountUtil

func LookupUnmountUtil(extraLookupPaths []string, fuse bool) (string, error)

func NewConfig

func NewConfig(name string) (interface{}, error)

func Register

func Register(name string, f FactoryFunc, cf ConfigFactoryFunc)

func RemoveAllOneFilesystem

func RemoveAllOneFilesystem(path string) error

RemoveAllOneFilesystem removes path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil (no error). It makes sure it does not cross mount boundary, i.e. it does *not* remove files from another filesystems. Like 'rm -rf --one-file-system'. It is copied from RemoveAll() sources, with IsLikelyNotMountPoint

func ResolveHostPathMountSource

func ResolveHostPathMountSource(
	path, podUID, volName string,
	remote bool,
	getRemoteVolumeDir func(podUID, volName string) string,
	getTmpfsVolumeDir func(podUID, volName string) string,
) (string, error)

func ResolveStorageCommand

func ResolveStorageCommand(bin string, args []string, remotePath, localPath string) []string

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(
	ctx context.Context,
	impl Interface,
	successTimeWait time.Duration,
	extraLookupPaths []string,
	stdoutFile, stderrFile string,
) (_ *Client, err error)

func (*Client) Close

func (c *Client) Close()

func (*Client) Mount

func (c *Client) Mount(
	ctx context.Context,
	remotePath, mountPoint string,
	onExited ExitHandleFunc,
) error

func (*Client) Unmount

func (c *Client) Unmount(ctx context.Context, mountPoint string) error

type ClientConfig

type ClientConfig struct {
	DriverConfig `json:",inline" yaml:",inline"`

	StdoutFile string `json:"stdoutFile" yaml:"stdoutFile"`
	StderrFile string `json:"stderrFile" yaml:"stderrFile"`

	SuccessTimeWait  time.Duration `json:"successTimeWait" yaml:"successTimeWait"`
	ExtraLookupPaths []string      `json:"extraLookupPaths" yaml:"extraLookupPaths"`
}

func (*ClientConfig) CreateClient

func (c *ClientConfig) CreateClient(ctx context.Context) (*Client, error)

type ConfigFactoryFunc

type ConfigFactoryFunc func() interface{}

type DriverConfig added in v0.1.5

type DriverConfig struct {
	Driver string      `json:"driver" yaml:"driver"`
	Config interface{} `json:"config" yaml:"config"`
}

func (*DriverConfig) UnmarshalJSON added in v0.1.5

func (c *DriverConfig) UnmarshalJSON(data []byte) error

func (*DriverConfig) UnmarshalYAML added in v0.1.5

func (c *DriverConfig) UnmarshalYAML(value *yaml.Node) error

type ExitHandleFunc

type ExitHandleFunc func(remotePath, mountPoint string, err error)

type FactoryFunc

type FactoryFunc func(config interface{}) (Interface, error)

type Interface

type Interface interface {
	GetMountCmd(remotePath, mountPoint string) []string
	GetUnmountCmd(mountPoint string) []string
}

func NewDriver

func NewDriver(name string, config interface{}) (Interface, error)

type NopConfig

type NopConfig struct{}

type NopDriver

type NopDriver struct{}

func (*NopDriver) GetMountCmd

func (d *NopDriver) GetMountCmd(remotePath, mountPoint string) []string

func (*NopDriver) GetUnmountCmd

func (d *NopDriver) GetUnmountCmd(mountPoint string) []string

Directories

Path Synopsis
Package general provides general purpose remote storage driver
Package general provides general purpose remote storage driver
Package sshfs provides sshfs based remote storage driver
Package sshfs provides sshfs based remote storage driver

Jump to

Keyboard shortcuts

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