From 050a98e8bba956a740d1018c4c17a37d47d5b276 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Wed, 29 Aug 2018 18:15:09 +0200 Subject: [PATCH] googlecompute builder: use config from statebag --- builder/googlecompute/builder.go | 1 - builder/googlecompute/step_create_ssh_key.go | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/builder/googlecompute/builder.go b/builder/googlecompute/builder.go index 1c0909989..b4a5f7bb9 100644 --- a/builder/googlecompute/builder.go +++ b/builder/googlecompute/builder.go @@ -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{ diff --git a/builder/googlecompute/step_create_ssh_key.go b/builder/googlecompute/step_create_ssh_key.go index 69742c5ea..889cf1b76 100644 --- a/builder/googlecompute/step_create_ssh_key.go +++ b/builder/googlecompute/step_create_ssh_key.go @@ -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))