Skip to content

Commit

Permalink
e2e: Make getConfigFile() generic
Browse files Browse the repository at this point in the history
Update the getConfigFile() function to allow any file to be looked
at on the preferred location first and fall back to the alternate
location if it does not exist there.

Signed-off-by: karthik-us <ksubrahm@redhat.com>
  • Loading branch information
karthik-us authored and mergify[bot] committed Jun 7, 2023
1 parent 6ac3a4d commit e4e373c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion e2e/cephfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func deleteCephfsPlugin() {
}

func createORDeleteCephfsResources(action kubectlAction) {
cephConfigFile := getConfigFile(deployPath + cephConfconfigMap)
cephConfigFile := getConfigFile(cephConfconfigMap, deployPath, examplePath)
resources := []ResourceDeployer{
// shared resources
&yamlResource{
Expand Down
2 changes: 1 addition & 1 deletion e2e/nfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion e2e/rbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func deleteRBDPlugin() {
}

func createORDeleteRbdResources(action kubectlAction) {
cephConfigFile := getConfigFile(deployPath + cephConfconfigMap)
cephConfigFile := getConfigFile(cephConfconfigMap, deployPath, examplePath)
resources := []ResourceDeployer{
// shared resources
&yamlResource{
Expand Down
9 changes: 5 additions & 4 deletions e2e/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e4e373c

Please sign in to comment.