From 9dad09b9d370e9da07de58d0a0d91ea1e3a45c35 Mon Sep 17 00:00:00 2001 From: Lars Lehtonen Date: Fri, 1 Nov 2019 18:58:14 -0700 Subject: [PATCH 1/2] builder/linode: remove unused sshConfig() function and associated import --- builder/linode/ssh.go | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/builder/linode/ssh.go b/builder/linode/ssh.go index 8f291c450..5142da9a6 100644 --- a/builder/linode/ssh.go +++ b/builder/linode/ssh.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/packer/helper/multistep" "github.com/linode/linodego" - "golang.org/x/crypto/ssh" ) func commHost(host string) func(multistep.StateBag) (string, error) { @@ -23,13 +22,3 @@ func commHost(host string) func(multistep.StateBag) (string, error) { return instance.IPv4[0].String(), nil } } - -func sshConfig(state multistep.StateBag) (*ssh.ClientConfig, error) { - return &ssh.ClientConfig{ - User: "root", - HostKeyCallback: ssh.InsecureIgnoreHostKey(), - Auth: []ssh.AuthMethod{ - ssh.Password(state.Get("root_pass").(string)), - }, - }, nil -} From af1e41793d26860e8a8385e37b65d625844530a8 Mon Sep 17 00:00:00 2001 From: Lars Lehtonen Date: Fri, 1 Nov 2019 19:02:52 -0700 Subject: [PATCH 2/2] builder/linode: move commHost() out of orphaned ssh.go --- builder/linode/builder.go | 16 ++++++++++++++++ builder/linode/ssh.go | 24 ------------------------ 2 files changed, 16 insertions(+), 24 deletions(-) delete mode 100644 builder/linode/ssh.go diff --git a/builder/linode/builder.go b/builder/linode/builder.go index def4b1f2e..3bc3dfb3f 100644 --- a/builder/linode/builder.go +++ b/builder/linode/builder.go @@ -6,6 +6,7 @@ import ( "context" "errors" "fmt" + "log" "github.com/hashicorp/packer/common" "github.com/linode/linodego" @@ -96,3 +97,18 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (ret return artifact, nil } + +func commHost(host string) func(multistep.StateBag) (string, error) { + return func(state multistep.StateBag) (string, error) { + if host != "" { + log.Printf("Using ssh_host value: %s", host) + return host, nil + } + + instance := state.Get("instance").(*linodego.Instance) + if len(instance.IPv4) == 0 { + return "", fmt.Errorf("Linode instance %d has no IPv4 addresses!", instance.ID) + } + return instance.IPv4[0].String(), nil + } +} diff --git a/builder/linode/ssh.go b/builder/linode/ssh.go deleted file mode 100644 index 5142da9a6..000000000 --- a/builder/linode/ssh.go +++ /dev/null @@ -1,24 +0,0 @@ -package linode - -import ( - "fmt" - "log" - - "github.com/hashicorp/packer/helper/multistep" - "github.com/linode/linodego" -) - -func commHost(host string) func(multistep.StateBag) (string, error) { - return func(state multistep.StateBag) (string, error) { - if host != "" { - log.Printf("Using ssh_host value: %s", host) - return host, nil - } - - instance := state.Get("instance").(*linodego.Instance) - if len(instance.IPv4) == 0 { - return "", fmt.Errorf("Linode instance %d has no IPv4 addresses!", instance.ID) - } - return instance.IPv4[0].String(), nil - } -}