mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
replace more powershell commands with /bin/sh in volume/fixtures.go
This commit is contained in:
parent
7aa8a497df
commit
6583b05f07
@ -568,47 +568,30 @@ func InjectContent(f *framework.Framework, config TestConfig, fsGroup *int64, fs
|
|||||||
// generateWriteCmd is used by generateWriteBlockCmd and generateWriteFileCmd
|
// generateWriteCmd is used by generateWriteBlockCmd and generateWriteFileCmd
|
||||||
func generateWriteCmd(content, path string) []string {
|
func generateWriteCmd(content, path string) []string {
|
||||||
var commands []string
|
var commands []string
|
||||||
if !framework.NodeOSDistroIs("windows") {
|
|
||||||
commands = []string{"/bin/sh", "-c", "echo '" + content + "' > " + path}
|
commands = []string{"/bin/sh", "-c", "echo '" + content + "' > " + path}
|
||||||
} else {
|
|
||||||
commands = []string{"powershell", "/c", "echo '" + content + "' > " + path}
|
|
||||||
}
|
|
||||||
return commands
|
return commands
|
||||||
}
|
}
|
||||||
|
|
||||||
// generateReadBlockCmd generates the corresponding command lines to read from a block device with the given file path.
|
// generateReadBlockCmd generates the corresponding command lines to read from a block device with the given file path.
|
||||||
// Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh
|
|
||||||
func generateReadBlockCmd(fullPath string, numberOfCharacters int) []string {
|
func generateReadBlockCmd(fullPath string, numberOfCharacters int) []string {
|
||||||
var commands []string
|
var commands []string
|
||||||
if !framework.NodeOSDistroIs("windows") {
|
|
||||||
commands = []string{"head", "-c", strconv.Itoa(numberOfCharacters), fullPath}
|
commands = []string{"head", "-c", strconv.Itoa(numberOfCharacters), fullPath}
|
||||||
} else {
|
|
||||||
// TODO: is there a way on windows to get the first X bytes from a device?
|
|
||||||
commands = []string{"powershell", "/c", "type " + fullPath}
|
|
||||||
}
|
|
||||||
return commands
|
return commands
|
||||||
}
|
}
|
||||||
|
|
||||||
// generateWriteBlockCmd generates the corresponding command lines to write to a block device the given content.
|
// generateWriteBlockCmd generates the corresponding command lines to write to a block device the given content.
|
||||||
// Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh
|
|
||||||
func generateWriteBlockCmd(content, fullPath string) []string {
|
func generateWriteBlockCmd(content, fullPath string) []string {
|
||||||
return generateWriteCmd(content, fullPath)
|
return generateWriteCmd(content, fullPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GenerateReadFileCmd generates the corresponding command lines to read from a file with the given file path.
|
// GenerateReadFileCmd generates the corresponding command lines to read from a file with the given file path.
|
||||||
// Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh
|
|
||||||
func GenerateReadFileCmd(fullPath string) []string {
|
func GenerateReadFileCmd(fullPath string) []string {
|
||||||
var commands []string
|
var commands []string
|
||||||
if !framework.NodeOSDistroIs("windows") {
|
|
||||||
commands = []string{"cat", fullPath}
|
commands = []string{"cat", fullPath}
|
||||||
} else {
|
|
||||||
commands = []string{"powershell", "/c", "type " + fullPath}
|
|
||||||
}
|
|
||||||
return commands
|
return commands
|
||||||
}
|
}
|
||||||
|
|
||||||
// generateWriteFileCmd generates the corresponding command lines to write a file with the given content and file path.
|
// generateWriteFileCmd generates the corresponding command lines to write a file with the given content and file path.
|
||||||
// Depending on the Node OS is Windows or linux, the command will use powershell or /bin/sh
|
|
||||||
func generateWriteFileCmd(content, fullPath string) []string {
|
func generateWriteFileCmd(content, fullPath string) []string {
|
||||||
return generateWriteCmd(content, fullPath)
|
return generateWriteCmd(content, fullPath)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user