Documentation ¶
Overview ¶
Package volume includes internal representations of external volume types as well as utility methods required to mount/unmount volumes to kubelets.
Index ¶
- func EscapePluginName(in string) string
- func RenameDirectory(oldPath, newName string) (string, error)
- func UnescapePluginName(in string) string
- type Builder
- type Cleaner
- type FakeHost
- type FakePlugin
- func (plugin *FakePlugin) CanSupport(spec *api.Volume) bool
- func (plugin *FakePlugin) Init(host Host)
- func (plugin *FakePlugin) Name() string
- func (plugin *FakePlugin) NewBuilder(spec *api.Volume, podUID types.UID) (Builder, error)
- func (plugin *FakePlugin) NewCleaner(volName string, podUID types.UID) (Cleaner, error)
- type FakeVolume
- type Host
- type Interface
- type Plugin
- type PluginMgr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EscapePluginName ¶
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 UnescapePluginName ¶
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 ¶
FakeHost is useful for testing volume plugins.
func (*FakeHost) GetKubeClient ¶ added in v0.4.1
func (*FakeHost) GetPluginDir ¶
func (*FakeHost) GetPodPluginDir ¶
type FakePlugin ¶
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 (*FakePlugin) NewCleaner ¶
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 // GetKubeClient returns a client interface GetKubeClient() client.Interface }
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 ¶
FindPluginByName fetches a plugin by name or by legacy name. If no plugin is found, returns error.
func (*PluginMgr) FindPluginBySpec ¶
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.