mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-22 22:30:23 +00:00
b891e5585d
This commit addresses ifshort linter issues which checks if short syntax for if-statements is possible. updates: #1586 Signed-off-by: Rakshith R <rar@redhat.com>
43 lines
1.1 KiB
Go
43 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
|
|
}
|