1
0
mirror of https://github.com/ceph/ceph-csi.git synced 2024-12-22 04:50:23 +00:00
ceph-csi/e2e/upgrade.go

43 lines
1.1 KiB
Go
Raw Normal View History

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
}