From 1fb4290c4eb6febba657f69eae9ed9408ac42ab7 Mon Sep 17 00:00:00 2001 From: Deep Debroy Date: Mon, 4 Mar 2019 19:13:05 -0800 Subject: [PATCH] Update API names and references Signed-off-by: Deep Debroy --- .../operationexecutor/operation_generator.go | 2 +- .../k8s.io/csi-translation-lib/translate.go | 18 ++++++++++-------- .../csi-translation-lib/translate_test.go | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/pkg/volume/util/operationexecutor/operation_generator.go b/pkg/volume/util/operationexecutor/operation_generator.go index d658c0766b7..c35a060daeb 100644 --- a/pkg/volume/util/operationexecutor/operation_generator.go +++ b/pkg/volume/util/operationexecutor/operation_generator.go @@ -440,7 +440,7 @@ func (og *operationGenerator) GenerateDetachVolumeFunc( // TODO(dyzz): This case can't distinguish between PV and In-line which is necessary because // if it was PV it may have been migrated, but the same plugin with in-line may not have been. // Suggestions welcome... - if csilib.IsMigratableByName(pluginName) && utilfeature.DefaultFeatureGate.Enabled(features.CSIMigration) { + if csilib.IsMigratableIntreePluginByName(pluginName) && utilfeature.DefaultFeatureGate.Enabled(features.CSIMigration) { // The volume represented by this spec is CSI and thus should be migrated attachableVolumePlugin, err = og.volumePluginMgr.FindAttachablePluginByName(csi.CSIPluginName) if err != nil || attachableVolumePlugin == nil { diff --git a/staging/src/k8s.io/csi-translation-lib/translate.go b/staging/src/k8s.io/csi-translation-lib/translate.go index 0456ec698d2..7f84a4f7cbf 100644 --- a/staging/src/k8s.io/csi-translation-lib/translate.go +++ b/staging/src/k8s.io/csi-translation-lib/translate.go @@ -75,9 +75,9 @@ func TranslateCSIPVToInTree(pv *v1.PersistentVolume) (*v1.PersistentVolume, erro return nil, fmt.Errorf("could not find in-tree plugin translation logic for %s", copiedPV.Spec.CSI.Driver) } -// IsMigratableByName tests whether there is Migration logic for the in-tree plugin -// whose name matches the given inTreePluginName -func IsMigratableByName(inTreePluginName string) bool { +// IsMigratableIntreePluginByName tests whether there is migration logic for the in-tree plugin +// whose name matches the given name +func IsMigratableIntreePluginByName(inTreePluginName string) bool { for _, curPlugin := range inTreePlugins { if curPlugin.GetInTreePluginName() == inTreePluginName { return true @@ -86,16 +86,17 @@ func IsMigratableByName(inTreePluginName string) bool { return false } -// SupersedesInTreePlugin tests whether there exists an in-tree plugin with logic -// to migrate to the CSI plugin with given name -func SupersedesInTreePlugin(csiPluginName string) bool { +// IsMigratedCSIDriverByName tests whether there exists an in-tree plugin with logic +// to migrate to the CSI driver with given name +func IsMigratedCSIDriverByName(csiPluginName string) bool { if _, ok := inTreePlugins[csiPluginName]; ok { return true } return false } -// GetCSINameFromInTreeName returns the name of a CSI driver that supersedes the in-tree plugin with the given name +// GetCSINameFromInTreeName returns the name of a CSI driver that supersedes the +// in-tree plugin with the given name func GetCSINameFromInTreeName(pluginName string) (string, error) { for csiDriverName, curPlugin := range inTreePlugins { if curPlugin.GetInTreePluginName() == pluginName { @@ -105,7 +106,8 @@ func GetCSINameFromInTreeName(pluginName string) (string, error) { return "", fmt.Errorf("Could not find CSI Driver name for plugin %v", pluginName) } -// GetInTreeNameFromCSIName returns the name of the in-tree plugin superseded by a CSI driver with the given name +// GetInTreeNameFromCSIName returns the name of the in-tree plugin superseded by +// a CSI driver with the given name func GetInTreeNameFromCSIName(pluginName string) (string, error) { if plugin, ok := inTreePlugins[pluginName]; ok { return plugin.GetInTreePluginName(), nil diff --git a/staging/src/k8s.io/csi-translation-lib/translate_test.go b/staging/src/k8s.io/csi-translation-lib/translate_test.go index c42ac6ebda2..f095ced630e 100644 --- a/staging/src/k8s.io/csi-translation-lib/translate_test.go +++ b/staging/src/k8s.io/csi-translation-lib/translate_test.go @@ -99,14 +99,14 @@ func TestPluginNameMappings(t *testing.T) { if err != nil { t.Errorf("Error when mapping In-tree plugin name to CSI plugin name %s", err) } - if !SupersedesInTreePlugin(csiPluginName) { + if !IsMigratedCSIDriverByName(csiPluginName) { t.Errorf("%s expected to supersede an In-tree plugin", csiPluginName) } inTreePluginName, err := GetInTreeNameFromCSIName(csiPluginName) if err != nil { t.Errorf("Error when mapping CSI plugin name to In-tree plugin name %s", err) } - if !IsMigratableByName(inTreePluginName) { + if !IsMigratableIntreePluginByName(inTreePluginName) { t.Errorf("%s expected to be migratable to a CSI name", inTreePluginName) } if inTreePluginName != test.inTreePluginName || csiPluginName != test.csiPluginName {