googlecompute builder: use config from statebag

This commit is contained in:
Adrien Delorme 2018-08-29 18:15:09 +02:00
parent b0c09087a2
commit 050a98e8bb
2 changed files with 2 additions and 5 deletions

View File

@ -52,7 +52,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
new(StepCheckExistingImage),
&StepCreateSSHKey{
Debug: b.config.PackerDebug,
Comm: &b.config.Comm,
DebugKeyPath: fmt.Sprintf("gce_%s.pem", b.config.PackerBuildName),
},
&StepCreateInstance{

View File

@ -10,7 +10,6 @@ import (
"io/ioutil"
"os"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"golang.org/x/crypto/ssh"
@ -19,7 +18,6 @@ import (
// StepCreateSSHKey represents a Packer build step that generates SSH key pairs.
type StepCreateSSHKey struct {
Debug bool
Comm *communicator.Config
DebugKeyPath string
}
@ -29,9 +27,9 @@ func (s *StepCreateSSHKey) Run(_ context.Context, state multistep.StateBag) mult
ui := state.Get("ui").(packer.Ui)
config := state.Get("config").(*Config)
if s.Comm.SSHPrivateKeyFile != "" {
if config.Comm.SSHPrivateKeyFile != "" {
ui.Say("Using existing SSH private key")
privateKeyBytes, err := ioutil.ReadFile(s.Comm.SSHPrivateKeyFile)
privateKeyBytes, err := ioutil.ReadFile(config.Comm.SSHPrivateKeyFile)
if err != nil {
state.Put("error", fmt.Errorf(
"Error loading configured private key file: %s", err))