fmt
This commit is contained in:
parent
e84e5e4f2c
commit
5fac6c79c4
@ -5,8 +5,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/mitchellh/packer/common/uuid"
|
|
||||||
"github.com/mitchellh/packer/common"
|
"github.com/mitchellh/packer/common"
|
||||||
|
"github.com/mitchellh/packer/common/uuid"
|
||||||
"github.com/mitchellh/packer/packer"
|
"github.com/mitchellh/packer/packer"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -170,13 +170,13 @@ func (d *driverGCE) RunInstance(c *InstanceConfig) (<-chan error, error) {
|
|||||||
Description: c.Description,
|
Description: c.Description,
|
||||||
Disks: []*compute.AttachedDisk{
|
Disks: []*compute.AttachedDisk{
|
||||||
&compute.AttachedDisk{
|
&compute.AttachedDisk{
|
||||||
Type: "PERSISTENT",
|
Type: "PERSISTENT",
|
||||||
Mode: "READ_WRITE",
|
Mode: "READ_WRITE",
|
||||||
Kind: "compute#attachedDisk",
|
Kind: "compute#attachedDisk",
|
||||||
Boot: true,
|
Boot: true,
|
||||||
AutoDelete: true,
|
AutoDelete: true,
|
||||||
InitializeParams: &compute.AttachedDiskInitializeParams{
|
InitializeParams: &compute.AttachedDiskInitializeParams{
|
||||||
SourceImage: image.SelfLink,
|
SourceImage: image.SelfLink,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -27,7 +27,7 @@ func SSHConfigFunc(config SSHConfig) func(multistep.StateBag) (*gossh.ClientConf
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
auth = append(auth, gossh.PublicKeys(signer))
|
auth = append(auth, gossh.PublicKeys(signer))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@ package iso
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/mitchellh/multistep"
|
"github.com/mitchellh/multistep"
|
||||||
"github.com/mitchellh/packer/packer"
|
|
||||||
vmwcommon "github.com/mitchellh/packer/builder/vmware/common"
|
vmwcommon "github.com/mitchellh/packer/builder/vmware/common"
|
||||||
|
"github.com/mitchellh/packer/packer"
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -47,13 +47,13 @@ func CheckUnusedConfig(md *mapstructure.Metadata) *packer.MultiError {
|
|||||||
|
|
||||||
// ChooseString returns the first non-empty value.
|
// ChooseString returns the first non-empty value.
|
||||||
func ChooseString(vals ...string) string {
|
func ChooseString(vals ...string) string {
|
||||||
for _, el := range vals {
|
for _, el := range vals {
|
||||||
if el != "" {
|
if el != "" {
|
||||||
return el
|
return el
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// DecodeConfig is a helper that handles decoding raw configuration using
|
// DecodeConfig is a helper that handles decoding raw configuration using
|
||||||
|
@ -31,7 +31,7 @@ func TestCheckUnusedConfig(t *testing.T) {
|
|||||||
|
|
||||||
func TestChooseString(t *testing.T) {
|
func TestChooseString(t *testing.T) {
|
||||||
cases := []struct {
|
cases := []struct {
|
||||||
Input []string
|
Input []string
|
||||||
Output string
|
Output string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
package ssh
|
package ssh
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"code.google.com/p/go.crypto/ssh"
|
"code.google.com/p/go.crypto/ssh"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
// An implementation of ssh.KeyboardInteractiveChallenge that simply sends
|
// An implementation of ssh.KeyboardInteractiveChallenge that simply sends
|
||||||
// back the password for all questions. The questions are logged.
|
// back the password for all questions. The questions are logged.
|
||||||
func PasswordKeyboardInteractive (password string) (ssh.KeyboardInteractiveChallenge) {
|
func PasswordKeyboardInteractive(password string) ssh.KeyboardInteractiveChallenge {
|
||||||
return func (user, instruction string, questions []string, echos []bool) ([]string, error) {
|
return func(user, instruction string, questions []string, echos []bool) ([]string, error) {
|
||||||
log.Printf("Keyboard interactive challenge: ")
|
log.Printf("Keyboard interactive challenge: ")
|
||||||
log.Printf("-- User: %s", user)
|
log.Printf("-- User: %s", user)
|
||||||
log.Printf("-- Instructions: %s", instruction)
|
log.Printf("-- Instructions: %s", instruction)
|
||||||
for i, question := range questions {
|
for i, question := range questions {
|
||||||
log.Printf("-- Question %d: %s", i+1, question)
|
log.Printf("-- Question %d: %s", i+1, question)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Just send the password back for all questions
|
// Just send the password back for all questions
|
||||||
answers := make([]string, len(questions))
|
answers := make([]string, len(questions))
|
||||||
for i, _ := range answers {
|
for i, _ := range answers {
|
||||||
answers[i] = string(password)
|
answers[i] = string(password)
|
||||||
}
|
}
|
||||||
|
|
||||||
return answers, nil
|
return answers, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ func TestPostProcessor_PostProcess(t *testing.T) {
|
|||||||
p := &PostProcessor{Driver: driver}
|
p := &PostProcessor{Driver: driver}
|
||||||
artifact := &packer.MockArtifact{
|
artifact := &packer.MockArtifact{
|
||||||
BuilderIdValue: dockerimport.BuilderId,
|
BuilderIdValue: dockerimport.BuilderId,
|
||||||
IdValue: "foo/bar",
|
IdValue: "foo/bar",
|
||||||
}
|
}
|
||||||
|
|
||||||
result, keep, err := p.PostProcess(testUi(), artifact)
|
result, keep, err := p.PostProcess(testUi(), artifact)
|
||||||
@ -64,7 +64,7 @@ func TestPostProcessor_PostProcess_portInName(t *testing.T) {
|
|||||||
p := &PostProcessor{Driver: driver}
|
p := &PostProcessor{Driver: driver}
|
||||||
artifact := &packer.MockArtifact{
|
artifact := &packer.MockArtifact{
|
||||||
BuilderIdValue: dockerimport.BuilderId,
|
BuilderIdValue: dockerimport.BuilderId,
|
||||||
IdValue: "localhost:5000/foo/bar",
|
IdValue: "localhost:5000/foo/bar",
|
||||||
}
|
}
|
||||||
|
|
||||||
result, keep, err := p.PostProcess(testUi(), artifact)
|
result, keep, err := p.PostProcess(testUi(), artifact)
|
||||||
@ -91,7 +91,7 @@ func TestPostProcessor_PostProcess_tags(t *testing.T) {
|
|||||||
p := &PostProcessor{Driver: driver}
|
p := &PostProcessor{Driver: driver}
|
||||||
artifact := &packer.MockArtifact{
|
artifact := &packer.MockArtifact{
|
||||||
BuilderIdValue: dockerimport.BuilderId,
|
BuilderIdValue: dockerimport.BuilderId,
|
||||||
IdValue: "hashicorp/ubuntu:precise",
|
IdValue: "hashicorp/ubuntu:precise",
|
||||||
}
|
}
|
||||||
|
|
||||||
result, keep, err := p.PostProcess(testUi(), artifact)
|
result, keep, err := p.PostProcess(testUi(), artifact)
|
||||||
|
@ -20,19 +20,19 @@ import (
|
|||||||
type Config struct {
|
type Config struct {
|
||||||
common.PackerConfig `mapstructure:",squash"`
|
common.PackerConfig `mapstructure:",squash"`
|
||||||
|
|
||||||
ConfigTemplate string `mapstructure:"config_template"`
|
ConfigTemplate string `mapstructure:"config_template"`
|
||||||
ExecuteCommand string `mapstructure:"execute_command"`
|
ExecuteCommand string `mapstructure:"execute_command"`
|
||||||
InstallCommand string `mapstructure:"install_command"`
|
InstallCommand string `mapstructure:"install_command"`
|
||||||
Json map[string]interface{}
|
Json map[string]interface{}
|
||||||
NodeName string `mapstructure:"node_name"`
|
NodeName string `mapstructure:"node_name"`
|
||||||
PreventSudo bool `mapstructure:"prevent_sudo"`
|
PreventSudo bool `mapstructure:"prevent_sudo"`
|
||||||
RunList []string `mapstructure:"run_list"`
|
RunList []string `mapstructure:"run_list"`
|
||||||
ServerUrl string `mapstructure:"server_url"`
|
ServerUrl string `mapstructure:"server_url"`
|
||||||
SkipCleanClient bool `mapstructure:"skip_clean_client"`
|
SkipCleanClient bool `mapstructure:"skip_clean_client"`
|
||||||
SkipCleanNode bool `mapstructure:"skip_clean_node"`
|
SkipCleanNode bool `mapstructure:"skip_clean_node"`
|
||||||
SkipInstall bool `mapstructure:"skip_install"`
|
SkipInstall bool `mapstructure:"skip_install"`
|
||||||
StagingDir string `mapstructure:"staging_directory"`
|
StagingDir string `mapstructure:"staging_directory"`
|
||||||
ValidationKeyPath string `mapstructure:"validation_key_path"`
|
ValidationKeyPath string `mapstructure:"validation_key_path"`
|
||||||
ValidationClientName string `mapstructure:"validation_client_name"`
|
ValidationClientName string `mapstructure:"validation_client_name"`
|
||||||
|
|
||||||
tpl *packer.ConfigTemplate
|
tpl *packer.ConfigTemplate
|
||||||
@ -43,9 +43,9 @@ type Provisioner struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ConfigTemplate struct {
|
type ConfigTemplate struct {
|
||||||
NodeName string
|
NodeName string
|
||||||
ServerUrl string
|
ServerUrl string
|
||||||
ValidationKeyPath string
|
ValidationKeyPath string
|
||||||
ValidationClientName string
|
ValidationClientName string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,9 +265,9 @@ func (p *Provisioner) createConfig(ui packer.Ui, comm packer.Communicator, nodeN
|
|||||||
}
|
}
|
||||||
|
|
||||||
configString, err := p.config.tpl.Process(tpl, &ConfigTemplate{
|
configString, err := p.config.tpl.Process(tpl, &ConfigTemplate{
|
||||||
NodeName: nodeName,
|
NodeName: nodeName,
|
||||||
ServerUrl: serverUrl,
|
ServerUrl: serverUrl,
|
||||||
ValidationKeyPath: remoteKeyPath,
|
ValidationKeyPath: remoteKeyPath,
|
||||||
ValidationClientName: validationClientName,
|
ValidationClientName: validationClientName,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user