mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-18 04:10:22 +00:00
43f753760b
nlreturn linter requires a new line before return and branch statements except when the return is alone inside a statement group (such as an if statement) to increase code clarity. This commit addresses such issues. Updates: #1586 Signed-off-by: Rakshith R <rar@redhat.com>
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package e2e
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"os"
|
|
"os/exec"
|
|
)
|
|
|
|
// upgradeCSI deploys a desired ceph-csi release version.
|
|
func upgradeCSI(version string) error {
|
|
tempDir := "/tmp/ceph-csi"
|
|
gitRepo := "https://github.com/ceph/ceph-csi.git"
|
|
// clone the desired release branch inside a temporary directory.
|
|
cmd := exec.Command("git", "clone", "--single-branch", "--branch", version, gitRepo, tempDir)
|
|
cmd.Stderr = os.Stderr
|
|
cmd.Stdout = os.Stdout
|
|
if err := cmd.Run(); err != nil {
|
|
return fmt.Errorf("unable to clone repo %s : %w", gitRepo, err)
|
|
}
|
|
err := os.Chdir(tempDir + "/e2e")
|
|
if err != nil {
|
|
return fmt.Errorf("unable to switch directory : %w", err)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// upgradeAndDeployCSI upgrades the CSI to a specific release.
|
|
func upgradeAndDeployCSI(version, testtype string) error {
|
|
if err := upgradeCSI(version); err != nil {
|
|
return fmt.Errorf("failed to upgrade driver %w", err)
|
|
}
|
|
switch testtype {
|
|
case "cephfs":
|
|
deployCephfsPlugin()
|
|
case "rbd":
|
|
deployRBDPlugin()
|
|
default:
|
|
return errors.New("incorrect test type, can be cephfs/rbd")
|
|
}
|
|
|
|
return nil
|
|
}
|