mirror of
https://github.com/hashicorp/packer.git
synced 2026-10-13 17:52:10 -04:00
go fmt
This commit is contained in:
@@ -2,13 +2,13 @@ package none
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
"io"
|
||||
"os"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
)
|
||||
|
||||
type comm struct {
|
||||
config string
|
||||
config string
|
||||
}
|
||||
|
||||
// Creates a null packer.Communicator implementation. This takes
|
||||
@@ -16,7 +16,7 @@ type comm struct {
|
||||
func New(config string) (result *comm, err error) {
|
||||
// Establish an initial connection and connect
|
||||
result = &comm{
|
||||
config: config,
|
||||
config: config,
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
@@ -147,8 +147,8 @@ func (c *Communicator) newCopyClient() (*winrmcp.Winrmcp, error) {
|
||||
User: c.config.Username,
|
||||
Password: c.config.Password,
|
||||
},
|
||||
Https: c.config.Https,
|
||||
Insecure: c.config.Insecure,
|
||||
Https: c.config.Https,
|
||||
Insecure: c.config.Insecure,
|
||||
OperationTimeout: c.config.Timeout,
|
||||
MaxOperationsPerShell: 15, // lowest common denominator
|
||||
})
|
||||
|
||||
@@ -5,9 +5,9 @@ import (
|
||||
"log"
|
||||
|
||||
"github.com/mitchellh/multistep"
|
||||
gossh "golang.org/x/crypto/ssh"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
"github.com/mitchellh/packer/communicator/none"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
gossh "golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
// StepConnect is a multistep Step implementation that connects to
|
||||
@@ -77,7 +77,7 @@ func (s *StepConnect) Run(state multistep.StateBag) multistep.StepAction {
|
||||
ui.Error(err.Error())
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
state.Put("communicator", comm)
|
||||
state.Put("communicator", comm)
|
||||
log.Printf("[INFO] communicator disabled, will not connect")
|
||||
return multistep.ActionContinue
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/mitchellh/packer/post-processor/shell-local"
|
||||
"github.com/mitchellh/packer/packer/plugin"
|
||||
"github.com/mitchellh/packer/post-processor/shell-local"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
@@ -111,17 +111,17 @@ func (p *Provisioner) Prepare(raws ...interface{}) error {
|
||||
|
||||
type Keys struct {
|
||||
//! This is the public key that we will allow to authenticate
|
||||
public ssh.PublicKey
|
||||
public ssh.PublicKey
|
||||
|
||||
//! This is the name of the file of the private key that coorlates
|
||||
//the the public key
|
||||
filename string
|
||||
|
||||
//! This is the servers private key ( Set in case the public key
|
||||
//is autogenerated )
|
||||
private ssh.Signer
|
||||
|
||||
//! This is the flag to say the server key was generated
|
||||
//! This is the servers private key ( Set in case the public key
|
||||
//is autogenerated )
|
||||
private ssh.Signer
|
||||
|
||||
//! This is the flag to say the server key was generated
|
||||
generated bool
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
||||
var private ssh.Signer
|
||||
var filename string = ""
|
||||
var generated bool = false
|
||||
|
||||
|
||||
if len(pubKeyFile) > 0 {
|
||||
pubKeyBytes, err := ioutil.ReadFile(pubKeyFile)
|
||||
if err != nil {
|
||||
@@ -177,7 +177,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
||||
filename = tf.Name()
|
||||
}
|
||||
|
||||
if len(privKeyFile) > 0 {
|
||||
if len(privKeyFile) > 0 {
|
||||
privateBytes, err := ioutil.ReadFile(privKeyFile)
|
||||
if err != nil {
|
||||
return nil, errors.New("Failed to load private host key")
|
||||
@@ -192,14 +192,14 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
||||
if err != nil {
|
||||
return nil, errors.New("Failed to generate server key pair")
|
||||
}
|
||||
|
||||
|
||||
private, err = ssh.NewSignerFromKey(key)
|
||||
if err != nil {
|
||||
return nil, errors.New("Failed to extract private key from generated key pair")
|
||||
}
|
||||
generated = true
|
||||
}
|
||||
return &Keys { public, filename, private, generated },nil
|
||||
return &Keys{public, filename, private, generated}, nil
|
||||
}
|
||||
|
||||
k, err := keyFactory(p.config.SSHAuthorizedKeyFile, p.config.SSHHostKeyFile)
|
||||
@@ -227,7 +227,7 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
|
||||
return nil, nil
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
config := &ssh.ServerConfig{
|
||||
AuthLogCallback: func(conn ssh.ConnMetadata, method string, err error) {
|
||||
ui.Say(fmt.Sprintf("authentication attempt from %s to %s as %s using %s", conn.RemoteAddr(), conn.LocalAddr(), conn.User(), method))
|
||||
@@ -321,20 +321,20 @@ func (p *Provisioner) executeAnsible(ui packer.Ui, comm packer.Communicator, aut
|
||||
playbook, _ := filepath.Abs(p.config.PlaybookFile)
|
||||
inventory := p.config.inventoryFile
|
||||
|
||||
args := []string{playbook, "-i", inventory }
|
||||
args := []string{playbook, "-i", inventory}
|
||||
if len(authToken) > 0 {
|
||||
args = append(args,"--private-key",authToken)
|
||||
args = append(args, "--private-key", authToken)
|
||||
}
|
||||
args = append(args, p.config.ExtraArguments...)
|
||||
|
||||
|
||||
cmd := exec.Command(p.config.Command, args...)
|
||||
|
||||
// If we have autogenerated the key files turn off host key checking
|
||||
if generated {
|
||||
cmd.Env = os.Environ()
|
||||
cmd.Env = append(cmd.Env,"ANSIBLE_HOST_KEY_CHECKING=False")
|
||||
cmd.Env = append(cmd.Env, "ANSIBLE_HOST_KEY_CHECKING=False")
|
||||
}
|
||||
|
||||
|
||||
stdout, err := cmd.StdoutPipe()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -216,7 +216,7 @@ func TestProvisioner_removeDir(t *testing.T) {
|
||||
for _, sudo := range []bool{true, false} {
|
||||
config := testConfig()
|
||||
config["prevent_sudo"] = !sudo
|
||||
|
||||
|
||||
p := &Provisioner{}
|
||||
comm := &packer.MockCommunicator{}
|
||||
ui := &packer.BasicUi{
|
||||
|
||||
@@ -69,4 +69,4 @@ func (g *GuestCommands) sudo(cmd string) string {
|
||||
return "sudo " + cmd
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,4 +117,4 @@ func TestRemoveDir(t *testing.T) {
|
||||
if cmd != "powershell.exe -Command \"rm C:\\Temp\\Some` Dir -recurse -force\"" {
|
||||
t.Fatalf("Unexpected Windows remove dir cmd: %s", cmd)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user