mirror of
https://github.com/containers/podman.git
synced 2026-03-13 08:01:19 +08:00
machine: prepend LocalhostSSHArgs to args
Rather than append LocalhostSSHArgs to args, prepend it, assuming the
order doesn't matter here.
This fixes the following prealloc warning (without decreasing
readability):
> cmd/podman/machine/cp.go:130:2: Consider preallocating args (prealloc)
> args := []string{"-r", "-i", sshConfig.IdentityPath, "-P", strconv.Itoa(sshConfig.Port)}
> ^
This commit is part of series fixing issues reported by prealloc linter
from golangci-lint v2.8.0.
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -127,10 +127,12 @@ func localhostSSHCopy(opts *cpOptions) error {
|
||||
destPath = username + destPath
|
||||
}
|
||||
|
||||
args := []string{"-r", "-i", sshConfig.IdentityPath, "-P", strconv.Itoa(sshConfig.Port)}
|
||||
args = append(args, machine.LocalhostSSHArgs()...) // Warning: This MUST NOT be generalized to allow communication over untrusted networks.
|
||||
args = append(args, []string{srcPath, destPath}...)
|
||||
|
||||
args := append(
|
||||
machine.LocalhostSSHArgs(), // Warning: This MUST NOT be generalized to allow communication over untrusted networks.
|
||||
"-r",
|
||||
"-i", sshConfig.IdentityPath,
|
||||
"-P", strconv.Itoa(sshConfig.Port),
|
||||
srcPath, destPath)
|
||||
cmd := exec.Command("scp", args...)
|
||||
if !opts.Quiet {
|
||||
cmd.Stdout = os.Stdout
|
||||
|
||||
@@ -127,7 +127,10 @@ func localhostNativeSSH(username, identityPath, name string, sshPort int, inputA
|
||||
port := strconv.Itoa(sshPort)
|
||||
interactive := true
|
||||
|
||||
args := append([]string{"-i", identityPath, "-p", port, sshDestination}, LocalhostSSHArgs()...) // WARNING: This MUST NOT be generalized to allow communication over untrusted networks.
|
||||
args := append(LocalhostSSHArgs(), // WARNING: This MUST NOT be generalized to allow communication over untrusted networks.
|
||||
"-i", identityPath,
|
||||
"-p", port,
|
||||
sshDestination)
|
||||
if len(inputArgs) > 0 {
|
||||
// on the other condition, the term is forced
|
||||
// anyway
|
||||
|
||||
Reference in New Issue
Block a user