volume

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2015 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package volume includes internal representations of external volume types as well as utility methods required to mount/unmount volumes to kubelets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapePluginName

func EscapePluginName(in string) string

EscapePluginName converts a plugin name, which might contain a / into a string that is safe to use on-disk. This assumes that the input has already been validates as a qualified name. we use "~" rather than ":" here in case we ever use a filesystem that doesn't allow ":".

func RenameDirectory

func RenameDirectory(oldPath, newName string) (string, error)

func UnescapePluginName

func UnescapePluginName(in string) string

UnescapePluginName converts an escaped plugin name (as per EscapePluginName) back to its normal form. This assumes that the input has already been validates as a qualified name.

Types

type Builder

type Builder interface {
	// Uses Interface to provide the path for Docker binds.
	Interface
	// SetUp prepares and mounts/unpacks the volume to a directory path.
	// This may be called more than once, so implementations must be
	// idempotent.
	SetUp() error
}

Builder interface provides method to set up/mount the volume.

type Cleaner

type Cleaner interface {
	Interface
	// TearDown unmounts the volume and removes traces of the SetUp procedure.
	TearDown() error
}

Cleaner interface provides method to cleanup/unmount the volumes.

type FakeHost

type FakeHost struct {
	RootDir string
}

FakeHost is useful for testing volume plugins.

func (*FakeHost) GetPluginDir

func (f *FakeHost) GetPluginDir(podUID string) string

func (*FakeHost) GetPodPluginDir

func (f *FakeHost) GetPodPluginDir(podUID types.UID, pluginName string) string

func (*FakeHost) GetPodVolumeDir

func (f *FakeHost) GetPodVolumeDir(podUID types.UID, pluginName, volumeName string) string

type FakePlugin

type FakePlugin struct {
	PluginName string
	Host       Host
}

FakePlugin is useful for for testing. It tries to be a fully compliant plugin, but all it does is make empty directories. Use as:

volume.RegisterPlugin(&FakePlugin{"fake-name"})

func (*FakePlugin) CanSupport

func (plugin *FakePlugin) CanSupport(spec *api.Volume) bool

func (*FakePlugin) Init

func (plugin *FakePlugin) Init(host Host)

func (*FakePlugin) Name

func (plugin *FakePlugin) Name() string

func (*FakePlugin) NewBuilder

func (plugin *FakePlugin) NewBuilder(spec *api.Volume, podUID types.UID) (Builder, error)

func (*FakePlugin) NewCleaner

func (plugin *FakePlugin) NewCleaner(volName string, podUID types.UID) (Cleaner, error)

type FakeVolume

type FakeVolume struct {
	PodUID  types.UID
	VolName string
	Plugin  *FakePlugin
}

func (*FakeVolume) GetPath

func (fv *FakeVolume) GetPath() string

func (*FakeVolume) SetUp

func (fv *FakeVolume) SetUp() error

func (*FakeVolume) TearDown

func (fv *FakeVolume) TearDown() error

type Host

type Host interface {
	// GetPluginDir returns the absolute path to a directory under which
	// a given plugin may store data.  This directory might not actually
	// exist on disk yet.  For plugin data that is per-pod, see
	// GetPodPluginDir().
	GetPluginDir(pluginName string) string

	// GetPodVolumeDir returns the absolute path a directory which
	// represents the named volume under the named plugin for the given
	// pod.  If the specified pod does not exist, the result of this call
	// might not exist.
	GetPodVolumeDir(podUID types.UID, pluginName string, volumeName string) string

	// GetPodPluginDir returns the absolute path to a directory under which
	// a given plugin may store data for a given pod.  If the specified pod
	// does not exist, the result of this call might not exist.  This
	// directory might not actually exist on disk yet.
	GetPodPluginDir(podUID types.UID, pluginName string) string
}

Host is an interface that plugins can use to access the kubelet.

type Interface

type Interface interface {
	// GetPath returns the directory path the volume is mounted to.
	GetPath() string
}

Interface is a directory used by pods or hosts. All method implementations of methods in the volume interface must be idempotent.

type Plugin

type Plugin interface {
	// Init initializes the plugin.  This will be called exactly once
	// before any New* calls are made - implementations of plugins may
	// depend on this.
	Init(host Host)

	// Name returns the plugin's name.  Plugins should use namespaced names
	// such as "example.com/volume".  The "kubernetes.io" namespace is
	// reserved for plugins which are bundled with kubernetes.
	Name() string

	// CanSupport tests whether the Plugin supports a given volume
	// specification from the API.  The spec pointer should be considered
	// const.
	CanSupport(spec *api.Volume) bool

	// NewBuilder creates a new volume.Builder from an API specification.
	// Ownership of the spec pointer in *not* transferred.
	// - spec: The api.Volume spec
	// - podUID: The UID of the enclosing pod
	NewBuilder(spec *api.Volume, podUID types.UID) (Builder, error)

	// NewCleaner creates a new volume.Cleaner from recoverable state.
	// - name: The volume name, as per the api.Volume spec.
	// - podUID: The UID of the enclosing pod
	NewCleaner(name string, podUID types.UID) (Cleaner, error)
}

Plugin is an interface to volume plugins.

type PluginMgr

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

PluginMgr tracks registered plugins.

func (*PluginMgr) FindPluginByName

func (pm *PluginMgr) FindPluginByName(name string) (Plugin, error)

FindPluginByName fetches a plugin by name or by legacy name. If no plugin is found, returns error.

func (*PluginMgr) FindPluginBySpec

func (pm *PluginMgr) FindPluginBySpec(spec *api.Volume) (Plugin, error)

FindPluginBySpec looks for a plugin that can support a given volume specification. If no plugins can support or more than one plugin can support it, return error.

func (*PluginMgr) InitPlugins

func (pm *PluginMgr) InitPlugins(plugins []Plugin, host Host) error

InitPlugins initializes each plugin. All plugins must have unique names. This must be called exactly once before any New* methods are called on any plugins.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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