本文整理匯總了Golang中k8s/io/kubernetes/pkg/util/strings.UnescapeQualifiedNameForDisk函數的典型用法代碼示例。如果您正苦於以下問題:Golang UnescapeQualifiedNameForDisk函數的具體用法?Golang UnescapeQualifiedNameForDisk怎麽用?Golang UnescapeQualifiedNameForDisk使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了UnescapeQualifiedNameForDisk函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newVolumeUnmounterFromPlugins
// newVolumeUnmounterFromPlugins attempts to find a plugin by name and then
// create an Unmounter.
// Returns a valid Unmounter or an error.
func (kl *Kubelet) newVolumeUnmounterFromPlugins(kind string, name string, podUID types.UID) (volume.Unmounter, string, error) {
plugName := strings.UnescapeQualifiedNameForDisk(kind)
plugin, err := kl.volumePluginMgr.FindPluginByName(plugName)
if err != nil {
// TODO: Maybe we should launch a cleanup of this dir?
return nil, "", fmt.Errorf("can't use volume plugins for %s/%s: %v", podUID, kind, err)
}
unmounter, err := plugin.NewUnmounter(name, podUID)
if err != nil {
return nil, "", fmt.Errorf("failed to instantiate volume plugin for %s/%s: %v", podUID, kind, err)
}
glog.V(5).Infof("Using volume plugin %q to unmount %s/%s", plugin.Name(), podUID, kind)
return unmounter, plugin.Name(), nil
}
示例2: getVolumesFromPodDir
// getVolumesFromPodDir scans through the volumes directories under the given pod directory.
// It returns a list of pod volume information including pod's uid, volume's plugin name, mount path,
// and volume spec name.
func getVolumesFromPodDir(podDir string) ([]podVolume, error) {
podsDirInfo, err := ioutil.ReadDir(podDir)
if err != nil {
return nil, err
}
volumes := []podVolume{}
for i := range podsDirInfo {
if !podsDirInfo[i].IsDir() {
continue
}
podName := podsDirInfo[i].Name()
podDir := path.Join(podDir, podName)
volumesDir := path.Join(podDir, options.DefaultKubeletVolumesDirName)
volumesDirInfo, err := ioutil.ReadDir(volumesDir)
if err != nil {
glog.Errorf("Could not read volume directory %q: %v", volumesDir, err)
continue
}
for _, volumeDir := range volumesDirInfo {
pluginName := volumeDir.Name()
volumePluginPath := path.Join(volumesDir, pluginName)
volumePluginDirs, err := ioutil.ReadDir(volumePluginPath)
if err != nil {
glog.Errorf("Could not read volume plugin directory %q: %v", volumePluginPath, err)
continue
}
unescapePluginName := strings.UnescapeQualifiedNameForDisk(pluginName)
for _, volumeNameDir := range volumePluginDirs {
if volumeNameDir != nil {
volumeName := volumeNameDir.Name()
mountPath := path.Join(volumePluginPath, volumeName)
volumes = append(volumes, podVolume{
podName: volumetypes.UniquePodName(podName),
volumeSpecName: volumeName,
mountPath: mountPath,
pluginName: unescapePluginName,
})
}
}
}
}
glog.V(10).Infof("Get volumes from pod directory %q %+v", podDir, volumes)
return volumes, nil
}
示例3: newVolumeDetacherFromPlugins
// newVolumeDetacherFromPlugins attempts to find a plugin by a name and then
// create a Detacher.
// Returns:
// - a detacher if one exists
// - an error if no plugin was found for the volume
// or the detacher failed to instantiate
// - nil if there is no appropriate detacher for this volume
func (kl *Kubelet) newVolumeDetacherFromPlugins(kind string, name string, podUID types.UID) (volume.Detacher, error) {
plugName := strings.UnescapeQualifiedNameForDisk(kind)
plugin, err := kl.volumePluginMgr.FindAttachablePluginByName(plugName)
if err != nil {
return nil, fmt.Errorf("can't use volume plugins for %s/%s: %v", podUID, kind, err)
}
if plugin == nil {
// Not found but not an error.
return nil, nil
}
detacher, err := plugin.NewDetacher()
if err != nil {
return nil, fmt.Errorf("failed to instantiate volume plugin for %s/%s: %v", podUID, kind, err)
}
return detacher, nil
}
示例4: newVolumeCleanerFromPlugins
func (kl *Kubelet) newVolumeCleanerFromPlugins(kind string, name string, podUID types.UID) (volume.Cleaner, error) {
plugName := strings.UnescapeQualifiedNameForDisk(kind)
plugin, err := kl.volumePluginMgr.FindPluginByName(plugName)
if err != nil {
// TODO: Maybe we should launch a cleanup of this dir?
return nil, fmt.Errorf("can't use volume plugins for %s/%s: %v", podUID, kind, err)
}
if plugin == nil {
// Not found but not an error.
return nil, nil
}
cleaner, err := plugin.NewCleaner(name, podUID)
if err != nil {
return nil, fmt.Errorf("failed to instantiate volume plugin for %s/%s: %v", podUID, kind, err)
}
glog.V(3).Infof("Used volume plugin %q for %s/%s", plugin.Name(), podUID, kind)
return cleaner, nil
}