use strconv.unquote instead of DIY

This commit is contained in:
Megan Marsh 2020-01-15 10:23:25 -08:00
parent 5980d32efb
commit bbd64896a0
2 changed files with 4 additions and 8 deletions

View File

@ -201,7 +201,7 @@ func (d *Vagrant_2_2_Driver) vagrantCmd(args ...string) (string, string, error)
err := cmd.Start()
if err != nil {
return "", "", fmt.Errorf("Error starting vagrant command with args: %s",
return "", "", fmt.Errorf("Error starting vagrant command with args: %q",
strings.Join(args, " "))
}

View File

@ -4,7 +4,6 @@ import (
"context"
"log"
"strconv"
"strings"
"github.com/hashicorp/packer/helper/multistep"
)
@ -57,12 +56,9 @@ func (s *StepSSHConfig) Run(ctx context.Context, state multistep.StateBag) multi
}
log.Printf("identity file is %s", sshConfig.IdentityFile)
log.Printf("Removing quotes from identity file")
if strings.HasPrefix(sshConfig.IdentityFile, "\"") {
sshConfig.IdentityFile = sshConfig.IdentityFile[1:]
if strings.HasSuffix(sshConfig.IdentityFile, "\"") {
sshConfig.IdentityFile = sshConfig.IdentityFile[:len(sshConfig.IdentityFile)-1]
}
log.Printf("identity file is now %s", sshConfig.IdentityFile)
sshConfig.IdentityFile, err = strconv.Unquote(sshConfig.IdentityFile)
if err != nil {
log.Printf("Error unquoting identity file: %s", err)
}
config.Comm.SSHPrivateKeyFile = sshConfig.IdentityFile
config.Comm.SSHUsername = sshConfig.User