Skip to content

Commit 18cb183

Browse files
committed
fix: appease linter, ensure no mutation
Signed-off-by: Bartek Mucha <muchzill4@gmail.com>
1 parent 5c3d467 commit 18cb183

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

cmd/limactl/shell.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,8 @@ func shellAction(cmd *cobra.Command, args []string) error {
212212
if err != nil {
213213
return err
214214
}
215-
sshArgs := sshutil.SSHArgsFromOpts(sshOpts)
215+
sshArgs := append([]string{}, sshExe.Args...)
216+
sshArgs = append(sshArgs, sshutil.SSHArgsFromOpts(sshOpts)...)
216217
if isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd()) {
217218
// required for showing the shell prompt: https://stackoverflow.com/a/626574
218219
sshArgs = append(sshArgs, "-t")
@@ -235,8 +236,7 @@ func shellAction(cmd *cobra.Command, args []string) error {
235236
"--",
236237
script,
237238
}...)
238-
allArgs := append(sshExe.Args, sshArgs...)
239-
sshCmd := exec.Command(sshExe.Exe, allArgs...)
239+
sshCmd := exec.Command(sshExe.Exe, sshArgs...)
240240
sshCmd.Stdin = os.Stdin
241241
sshCmd.Stdout = os.Stdout
242242
sshCmd.Stderr = os.Stderr

cmd/limactl/tunnel.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ func tunnelAction(cmd *cobra.Command, args []string) error {
9898
if err != nil {
9999
return err
100100
}
101-
sshArgs := sshutil.SSHArgsFromOpts(sshOpts)
101+
sshArgs := append([]string{}, sshExe.Args...)
102+
sshArgs = append(sshArgs, sshutil.SSHArgsFromOpts(sshOpts)...)
102103
sshArgs = append(sshArgs, []string{
103104
"-q", // quiet
104105
"-f", // background
@@ -107,8 +108,7 @@ func tunnelAction(cmd *cobra.Command, args []string) error {
107108
"-p", strconv.Itoa(inst.SSHLocalPort),
108109
inst.SSHAddress,
109110
}...)
110-
allArgs := append(sshExe.Args, sshArgs...)
111-
sshCmd := exec.Command(sshExe.Exe, allArgs...)
111+
sshCmd := exec.Command(sshExe.Exe, sshArgs...)
112112
sshCmd.Stdout = stderr
113113
sshCmd.Stderr = stderr
114114
logrus.Debugf("executing ssh (may take a long)): %+v", sshCmd.Args)

pkg/sshutil/sshutil.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,10 @@ func detectOpenSSHInfo(sshExe SSHExe) openSSHInfo {
387387
return *info
388388
}
389389
}
390+
sshArgs := append([]string{}, sshExe.Args...)
390391
// -V should be last
391-
allArgs := append(sshExe.Args, "-o", "GSSAPIAuthentication=no", "-V")
392-
cmd := exec.Command(sshExe.Exe, allArgs...)
392+
sshArgs = append(sshArgs, "-o", "GSSAPIAuthentication=no", "-V")
393+
cmd := exec.Command(sshExe.Exe, sshArgs...)
393394
cmd.Stderr = &stderr
394395
if err := cmd.Run(); err != nil {
395396
logrus.Warnf("failed to run %v: stderr=%q", cmd.Args, stderr.String())

0 commit comments

Comments
 (0)