diff --git a/e2e/cephfs.go b/e2e/cephfs.go index b10498e14..1a2388301 100644 --- a/e2e/cephfs.go +++ b/e2e/cephfs.go @@ -67,7 +67,7 @@ func deleteCephfsPlugin() { } func createORDeleteCephfsResources(action kubectlAction) { - cephConfigFile := getConfigFile(deployPath + cephConfconfigMap) + cephConfigFile := getConfigFile(cephConfconfigMap, deployPath, examplePath) resources := []ResourceDeployer{ // shared resources &yamlResource{ diff --git a/e2e/nfs.go b/e2e/nfs.go index 06d2f80b5..d06e06e4e 100644 --- a/e2e/nfs.go +++ b/e2e/nfs.go @@ -79,7 +79,7 @@ func deleteNFSPlugin() { } func createORDeleteNFSResources(f *framework.Framework, action kubectlAction) { - cephConfigFile := getConfigFile(deployPath + cephConfconfigMap) + cephConfigFile := getConfigFile(cephConfconfigMap, deployPath, examplePath) resources := []ResourceDeployer{ // shared resources &yamlResource{ diff --git a/e2e/rbd.go b/e2e/rbd.go index c820dee32..6bac023da 100644 --- a/e2e/rbd.go +++ b/e2e/rbd.go @@ -130,7 +130,7 @@ func deleteRBDPlugin() { } func createORDeleteRbdResources(action kubectlAction) { - cephConfigFile := getConfigFile(deployPath + cephConfconfigMap) + cephConfigFile := getConfigFile(cephConfconfigMap, deployPath, examplePath) resources := []ResourceDeployer{ // shared resources &yamlResource{ diff --git a/e2e/utils.go b/e2e/utils.go index 9150a791f..4a748f15d 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -1733,11 +1733,12 @@ func rwopMayFail(err error) bool { return !rwopSupported } -// getConfigFile returns the passed config file location if it exists, else -// returns the old location of the config file under 'examples/' directory. -func getConfigFile(configFile string) string { +// getConfigFile returns the config file path at the preferred location if it +// exists there. Returns the fallback location otherwise. +func getConfigFile(filename, preferred, fallback string) string { + configFile := preferred + filename if _, err := os.Stat(configFile); os.IsNotExist(err) { - configFile = examplePath + cephConfconfigMap + configFile = fallback + filename } return configFile