builder.oracle: use c.Comm for ssh
This commit is contained in:
parent
92570a2725
commit
0f9eddda3a
|
@ -64,8 +64,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
steps := []multistep.Step{
|
||||
&ocommon.StepKeyPair{
|
||||
Debug: b.config.PackerDebug,
|
||||
Comm: &b.config.Comm,
|
||||
DebugKeyPath: fmt.Sprintf("oci_classic_%s.pem", b.config.PackerBuildName),
|
||||
PrivateKeyFile: b.config.Comm.SSHPrivateKeyFile,
|
||||
},
|
||||
&stepCreateIPReservation{},
|
||||
&stepAddKeysToAPI{},
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/hashicorp/packer/helper/communicator"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"golang.org/x/crypto/ssh"
|
||||
|
@ -18,15 +19,15 @@ import (
|
|||
|
||||
type StepKeyPair struct {
|
||||
Debug bool
|
||||
Comm *communicator.Config
|
||||
DebugKeyPath string
|
||||
PrivateKeyFile string
|
||||
}
|
||||
|
||||
func (s *StepKeyPair) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
|
||||
if s.PrivateKeyFile != "" {
|
||||
privateKeyBytes, err := ioutil.ReadFile(s.PrivateKeyFile)
|
||||
if s.Comm.SSHPrivateKeyFile != "" {
|
||||
privateKeyBytes, err := ioutil.ReadFile(s.Comm.SSHPrivateKeyFile)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("Error loading configured private key file: %s", err)
|
||||
ui.Error(err.Error())
|
||||
|
@ -42,8 +43,8 @@ func (s *StepKeyPair) Run(_ context.Context, state multistep.StateBag) multistep
|
|||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
state.Put("publicKey", string(ssh.MarshalAuthorizedKey(key.PublicKey())))
|
||||
state.Put("privateKey", string(privateKeyBytes))
|
||||
s.Comm.SSHPublicKey = ssh.MarshalAuthorizedKey(key.PublicKey())
|
||||
s.Comm.SSHPrivateKey = privateKeyBytes
|
||||
|
||||
return multistep.ActionContinue
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
steps := []multistep.Step{
|
||||
&ocommon.StepKeyPair{
|
||||
Debug: b.config.PackerDebug,
|
||||
Comm: &b.config.Comm,
|
||||
DebugKeyPath: fmt.Sprintf("oci_%s.pem", b.config.PackerBuildName),
|
||||
PrivateKeyFile: b.config.Comm.SSHPrivateKeyFile,
|
||||
},
|
||||
&stepCreateInstance{},
|
||||
&stepInstanceInfo{},
|
||||
|
|
Loading…
Reference in New Issue