{"modulePath":"github.com/dockerstack/kubernetes","version":"v0.20.1-0.20150627061651-1c0b765df6da","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package volume\n\nPackage volume includes internal representations of external volume types as well as utility methods required to mount/unmount volumes to kubelets.\n\n## Functions\n\n```go\nfunc GetAccessModesAsString(modes []api.PersistentVolumeAccessMode) string\n```\n\n```go\nfunc NewFakeVolumeHost(rootDir string, kubeClient client.Interface, plugins []VolumePlugin) *fakeVolumeHost\n```\n\n```go\nfunc RenameDirectory(oldPath, newName string) (string, error)\n```\n\n```go\nfunc ScrubPodVolumeAndWatchUntilCompletion(pod *api.Pod, kubeClient client.Interface) error\n```\nScrubPodVolumeAndWatchUntilCompletion is intended for use with volume Recyclers.  This function will save the given Pod to the API and watch it until it completes, fails, or the pod's ActiveDeadlineSeconds is exceeded, whichever comes first. An attempt to delete a scrubber pod is always attempted before returning.\n\n\tpod - the pod designed by a volume plugin to scrub the volume's contents\n\tclient - kube client for API operations.\n\n## Types\n\n```go\ntype Builder interface {\n\t// Uses Interface to provide the path for Docker binds.\n\tVolume\n\t// SetUp prepares and mounts/unpacks the volume to a self-determined\n\t// directory path.  This may be called more than once, so\n\t// implementations must be idempotent.\n\tSetUp() error\n\t// SetUpAt prepares and mounts/unpacks the volume to the specified\n\t// directory path, which may or may not exist yet.  This may be called\n\t// more than once, so implementations must be idempotent.\n\tSetUpAt(dir string) error\n}\n```\nBuilder interface provides methods to set up/mount the volume.\n\n```go\ntype Cleaner interface {\n\tVolume\n\t// TearDown unmounts the volume from a self-determined directory and\n\t// removes traces of the SetUp procedure.\n\tTearDown() error\n\t// TearDown unmounts the volume from the specified directory and\n\t// removes traces of the SetUp procedure.\n\tTearDownAt(dir string) error\n}\n```\nCleaner interface provides methods to cleanup/unmount the volumes.\n\n```go\ntype FakeRecycler struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (fr *FakeRecycler) GetPath() string\n```\n\n```go\nfunc (fr *FakeRecycler) Recycle() error\n```\n\n```go\ntype FakeVolume struct {\n\tPodUID  types.UID\n\tVolName string\n\tPlugin  *FakeVolumePlugin\n}\n```\n\n```go\nfunc (fv *FakeVolume) GetPath() string\n```\n\n```go\nfunc (fv *FakeVolume) SetUp() error\n```\n\n```go\nfunc (fv *FakeVolume) SetUpAt(dir string) error\n```\n\n```go\nfunc (fv *FakeVolume) TearDown() error\n```\n\n```go\nfunc (fv *FakeVolume) TearDownAt(dir string) error\n```\n\n```go\ntype FakeVolumePlugin struct {\n\tPluginName string\n\tHost       VolumeHost\n}\n```\nFakeVolumePlugin is useful for testing.  It tries to be a fully compliant plugin, but all it does is make empty directories. Use as:\n\n\tvolume.RegisterPlugin(\u0026FakePlugin{\"fake-name\"})\n\n```go\nfunc (plugin *FakeVolumePlugin) CanSupport(spec *Spec) bool\n```\n\n```go\nfunc (plugin *FakeVolumePlugin) GetAccessModes() []api.PersistentVolumeAccessMode\n```\n\n```go\nfunc (plugin *FakeVolumePlugin) Init(host VolumeHost)\n```\n\n```go\nfunc (plugin *FakeVolumePlugin) Name() string\n```\n\n```go\nfunc (plugin *FakeVolumePlugin) NewBuilder(spec *Spec, pod *api.Pod, opts VolumeOptions, mounter mount.Interface) (Builder, error)\n```\n\n```go\nfunc (plugin *FakeVolumePlugin) NewCleaner(volName string, podUID types.UID, mounter mount.Interface) (Cleaner, error)\n```\n\n```go\nfunc (plugin *FakeVolumePlugin) NewRecycler(spec *Spec) (Recycler, error)\n```\n\n```go\ntype PersistentVolumePlugin interface {\n\tVolumePlugin\n\t// GetAccessModes describes the ways a given volume can be accessed/mounted.\n\tGetAccessModes() []api.PersistentVolumeAccessMode\n}\n```\nPersistentVolumePlugin is an extended interface of VolumePlugin and is used by volumes that want to provide long term persistence of data\n\n```go\ntype RecyclableVolumePlugin interface {\n\tVolumePlugin\n\t// NewRecycler creates a new volume.Recycler which knows how to reclaim this resource\n\t// after the volume's release from a PersistentVolumeClaim\n\tNewRecycler(spec *Spec) (Recycler, error)\n}\n```\nRecyclableVolumePlugin is an extended interface of VolumePlugin and is used by persistent volumes that want to be recycled before being made available again to new claims\n\n```go\ntype Recycler interface {\n\tVolume\n\t// Recycle reclaims the resource.  Calls to this method should block until the recycling task is complete.\n\t// Any error returned indicates the volume has failed to be reclaimed.  A nil return indicates success.\n\tRecycle() error\n}\n```\nRecycler provides methods to reclaim the volume resource.\n\n```go\ntype Spec struct {\n\tName                   string\n\tVolumeSource           api.VolumeSource\n\tPersistentVolumeSource api.PersistentVolumeSource\n}\n```\nSpec is an internal representation of a volume.  All API volume types translate to Spec.\n\n```go\nfunc NewSpecFromPersistentVolume(pv *api.PersistentVolume) *Spec\n```\nNewSpecFromPersistentVolume creates an Spec from an api.PersistentVolume\n\n```go\nfunc NewSpecFromVolume(vs *api.Volume) *Spec\n```\nNewSpecFromVolume creates an Spec from an api.Volume\n\n```go\ntype Volume interface {\n\t// GetPath returns the directory path the volume is mounted to.\n\tGetPath() string\n}\n```\nVolume represents a directory used by pods or hosts on a node. All method implementations of methods in the volume interface must be idempotent.\n\n```go\ntype VolumeHost interface {\n\t// GetPluginDir returns the absolute path to a directory under which\n\t// a given plugin may store data.  This directory might not actually\n\t// exist on disk yet.  For plugin data that is per-pod, see\n\t// GetPodPluginDir().\n\tGetPluginDir(pluginName string) string\n\n\t// GetPodVolumeDir returns the absolute path a directory which\n\t// represents the named volume under the named plugin for the given\n\t// pod.  If the specified pod does not exist, the result of this call\n\t// might not exist.\n\tGetPodVolumeDir(podUID types.UID, pluginName string, volumeName string) string\n\n\t// GetPodPluginDir returns the absolute path to a directory under which\n\t// a given plugin may store data for a given pod.  If the specified pod\n\t// does not exist, the result of this call might not exist.  This\n\t// directory might not actually exist on disk yet.\n\tGetPodPluginDir(podUID types.UID, pluginName string) string\n\n\t// GetKubeClient returns a client interface\n\tGetKubeClient() client.Interface\n\n\t// NewWrapperBuilder finds an appropriate plugin with which to handle\n\t// the provided spec.  This is used to implement volume plugins which\n\t// \"wrap\" other plugins.  For example, the \"secret\" volume is\n\t// implemented in terms of the \"emptyDir\" volume.\n\tNewWrapperBuilder(spec *Spec, pod *api.Pod, opts VolumeOptions, mounter mount.Interface) (Builder, error)\n\n\t// NewWrapperCleaner finds an appropriate plugin with which to handle\n\t// the provided spec.  See comments on NewWrapperBuilder for more\n\t// context.\n\tNewWrapperCleaner(spec *Spec, podUID types.UID, mounter mount.Interface) (Cleaner, error)\n}\n```\nVolumeHost is an interface that plugins can use to access the kubelet.\n\n```go\ntype VolumeOptions struct {\n\t// The rootcontext to use when performing mounts for a volume.\n\tRootContext string\n}\n```\nVolumeOptions contains option information about a volume.\n\nCurrently, this struct containers only a single field for the rootcontext of the volume.  This is a temporary measure in order to set the rootContext of tmpfs mounts correctly; it will be replaced and expanded on by future SecurityContext work.\n\n```go\ntype VolumePlugin interface {\n\t// Init initializes the plugin.  This will be called exactly once\n\t// before any New* calls are made - implementations of plugins may\n\t// depend on this.\n\tInit(host VolumeHost)\n\n\t// Name returns the plugin's name.  Plugins should use namespaced names\n\t// such as \"example.com/volume\".  The \"kubernetes.io\" namespace is\n\t// reserved for plugins which are bundled with kubernetes.\n\tName() string\n\n\t// CanSupport tests whether the plugin supports a given volume\n\t// specification from the API.  The spec pointer should be considered\n\t// const.\n\tCanSupport(spec *Spec) bool\n\n\t// NewBuilder creates a new volume.Builder from an API specification.\n\t// Ownership of the spec pointer in *not* transferred.\n\t// - spec: The api.Volume spec\n\t// - pod: The enclosing pod\n\tNewBuilder(spec *Spec, podRef *api.Pod, opts VolumeOptions, mounter mount.Interface) (Builder, error)\n\n\t// NewCleaner creates a new volume.Cleaner from recoverable state.\n\t// - name: The volume name, as per the api.Volume spec.\n\t// - podUID: The UID of the enclosing pod\n\tNewCleaner(name string, podUID types.UID, mounter mount.Interface) (Cleaner, error)\n}\n```\nVolumePlugin is an interface to volume plugins that can be used on a kubernetes node (e.g. by kubelet) to instantiate and manage volumes.\n\n```go\ntype VolumePluginMgr struct {\n\t// contains filtered or unexported fields\n}\n```\nVolumePluginMgr tracks registered plugins.\n\n```go\nfunc (pm *VolumePluginMgr) FindPersistentPluginByName(name string) (PersistentVolumePlugin, error)\n```\nFindPersistentPluginByName fetches a persistent volume plugin by name.  If no plugin is found, returns error.\n\n```go\nfunc (pm *VolumePluginMgr) FindPersistentPluginBySpec(spec *Spec) (PersistentVolumePlugin, error)\n```\nFindPersistentPluginBySpec looks for a persistent volume plugin that can support a given volume specification.  If no plugin is found, return an error\n\n```go\nfunc (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error)\n```\nFindPluginByName fetches a plugin by name or by legacy name.  If no plugin is found, returns error.\n\n```go\nfunc (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error)\n```\nFindPluginBySpec 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.\n\n```go\nfunc (pm *VolumePluginMgr) FindRecyclablePluginBySpec(spec *Spec) (RecyclableVolumePlugin, error)\n```\nFindRecyclablePluginByName fetches a persistent volume plugin by name.  If no plugin is found, returns error.\n\n```go\nfunc (pm *VolumePluginMgr) InitPlugins(plugins []VolumePlugin, host VolumeHost) error\n```\nInitPlugins initializes each plugin.  All plugins must have unique names. This must be called exactly once before any New\\* methods are called on any plugins.\n\n","path":"github.com/dockerstack/kubernetes/pkg/volume","name":"volume","synopsis":"Package volume includes internal representations of external volume types as well as utility methods required to mount/unmount volumes to kubelets.","isRedistributable":true}
