mirror of https://github.com/k3s-io/k3s
remove getAvailableDriveLetter func and test
parent
5275598d35
commit
c9070ffa8c
|
@ -256,20 +256,6 @@ func normalizeWindowsPath(path string) string {
|
|||
return normalizedPath
|
||||
}
|
||||
|
||||
func getAvailableDriveLetter() (string, error) {
|
||||
cmd := "$used = Get-PSDrive | Select-Object -Expand Name | Where-Object { $_.Length -eq 1 }"
|
||||
cmd += ";$drive = 67..90 | ForEach-Object { [string][char]$_ } | Where-Object { $used -notcontains $_ } | Select-Object -First 1;$drive"
|
||||
output, err := exec.Command("powershell", "/c", cmd).CombinedOutput()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("getAvailableDriveLetter failed: %v, output: %q", err, string(output))
|
||||
}
|
||||
|
||||
if len(output) == 0 {
|
||||
return "", fmt.Errorf("azureMount: there is no available drive letter now")
|
||||
}
|
||||
return string(output)[:1], nil
|
||||
}
|
||||
|
||||
// ValidateDiskNumber : disk number should be a number in [0, 99]
|
||||
func ValidateDiskNumber(disk string) error {
|
||||
diskNum, err := strconv.Atoi(disk)
|
||||
|
|
|
@ -22,12 +22,6 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func TestGetAvailableDriveLetter(t *testing.T) {
|
||||
if _, err := getAvailableDriveLetter(); err != nil {
|
||||
t.Errorf("getAvailableDriveLetter test failed : %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNormalizeWindowsPath(t *testing.T) {
|
||||
path := `/var/lib/kubelet/pods/146f8428-83e7-11e7-8dd4-000d3a31dac4/volumes/kubernetes.io~azure-disk`
|
||||
normalizedPath := normalizeWindowsPath(path)
|
||||
|
|
Loading…
Reference in New Issue