From 99c3872a48bd422e152ab91d517b4b4fe7ffd1b5 Mon Sep 17 00:00:00 2001 From: Jeff Wong Date: Mon, 14 Sep 2020 11:58:50 -0700 Subject: [PATCH] run go fmt --- builder/proxmox/clone/builder.go | 60 ++++++++++++------------- builder/proxmox/clone/config.go | 4 +- builder/proxmox/common/builder.go | 16 +++---- builder/proxmox/common/step_start_vm.go | 4 +- 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/builder/proxmox/clone/builder.go b/builder/proxmox/clone/builder.go index 9ef8f9dcc..7dfb906a8 100644 --- a/builder/proxmox/clone/builder.go +++ b/builder/proxmox/clone/builder.go @@ -2,14 +2,14 @@ package proxmoxclone import ( "context" - "time" - "fmt" + "fmt" + "time" proxmoxapi "github.com/Telmate/proxmox-api-go/proxmox" "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/builder/proxmox/common" - "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/helper/communicator" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" ) @@ -34,15 +34,15 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("clone-config", &b.config) - state.Put("comm", &b.config.Comm) + state.Put("comm", &b.config.Comm) preSteps := []multistep.Step{ - &StepSshKeyPair{ - Debug: b.config.PackerDebug, + &StepSshKeyPair{ + Debug: b.config.PackerDebug, DebugKeyPath: fmt.Sprintf("%s.pem", b.config.PackerBuildName), Comm: &b.config.Comm, - }, - } + }, + } postSteps := []multistep.Step{} sb := proxmox.NewSharedBuilder(BuilderID, b.config.Config, preSteps, postSteps, &cloneVMCreator{}) @@ -53,29 +53,29 @@ type cloneVMCreator struct{} func (*cloneVMCreator) Create(vmRef *proxmoxapi.VmRef, config proxmoxapi.ConfigQemu, state multistep.StateBag) error { client := state.Get("proxmoxClient").(*proxmoxapi.Client) - c := state.Get("clone-config").(*Config) - comm := state.Get("comm").(*communicator.Config) + c := state.Get("clone-config").(*Config) + comm := state.Get("comm").(*communicator.Config) - fullClone := 1 - if c.FullClone { - fullClone = 0 - } + fullClone := 1 + if c.FullClone { + fullClone = 0 + } - config.FullClone = &fullClone - config.CIuser = comm.SSHUsername - config.Sshkeys = string(comm.SSHPublicKey) - sourceVmr, err := client.GetVmRefByName(c.CloneVM) - if err != nil { - return err - } - err = config.CloneVm(sourceVmr, vmRef, client) - if err != nil { - return err - } - err = config.UpdateConfig(vmRef, client) - if err != nil { - return err - } - time.Sleep(time.Duration(15) * time.Second) + config.FullClone = &fullClone + config.CIuser = comm.SSHUsername + config.Sshkeys = string(comm.SSHPublicKey) + sourceVmr, err := client.GetVmRefByName(c.CloneVM) + if err != nil { + return err + } + err = config.CloneVm(sourceVmr, vmRef, client) + if err != nil { + return err + } + err = config.UpdateConfig(vmRef, client) + if err != nil { + return err + } + time.Sleep(time.Duration(15) * time.Second) return nil } diff --git a/builder/proxmox/clone/config.go b/builder/proxmox/clone/config.go index d481d3c39..3b8d2d5c6 100644 --- a/builder/proxmox/clone/config.go +++ b/builder/proxmox/clone/config.go @@ -10,8 +10,8 @@ import ( type Config struct { proxmox.Config `mapstructure:",squash"` - CloneVM string `mapstructure:"clone_vm"` - FullClone bool `mapstructure:"full_clone"` + CloneVM string `mapstructure:"clone_vm"` + FullClone bool `mapstructure:"full_clone"` } func (c *Config) Prepare(raws ...interface{}) ([]string, []string, error) { diff --git a/builder/proxmox/common/builder.go b/builder/proxmox/common/builder.go index 0ba157a63..74b44a883 100644 --- a/builder/proxmox/common/builder.go +++ b/builder/proxmox/common/builder.go @@ -19,7 +19,7 @@ func NewSharedBuilder(id string, config Config, preSteps []multistep.Step, postS config: config, preSteps: preSteps, postSteps: postSteps, - vmCreator: vmCreator, + vmCreator: vmCreator, } } @@ -30,7 +30,7 @@ type Builder struct { postSteps []multistep.Step runner multistep.Runner proxmoxClient *proxmox.Client - vmCreator ProxmoxVMCreator + vmCreator ProxmoxVMCreator } func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook, state multistep.StateBag) (packer.Artifact, error) { @@ -54,16 +54,16 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook, state state.Put("hook", hook) state.Put("ui", ui) - comm := &b.config.Comm - if(state.Get("comm") != nil) { - comm = state.Get("comm").(*communicator.Config) - } + comm := &b.config.Comm + if state.Get("comm") != nil { + comm = state.Get("comm").(*communicator.Config) + } // Build the steps coreSteps := []multistep.Step{ &stepStartVM{ - vmCreator: b.vmCreator, - }, + vmCreator: b.vmCreator, + }, &common.StepHTTPServer{ HTTPDir: b.config.HTTPDir, HTTPPortMin: b.config.HTTPPortMin, diff --git a/builder/proxmox/common/step_start_vm.go b/builder/proxmox/common/step_start_vm.go index 009cf5c35..5631dfa07 100644 --- a/builder/proxmox/common/step_start_vm.go +++ b/builder/proxmox/common/step_start_vm.go @@ -15,8 +15,8 @@ import ( // // It sets the vmRef state which is used throughout the later steps to reference the VM // in API calls. -type stepStartVM struct{ - vmCreator ProxmoxVMCreator +type stepStartVM struct { + vmCreator ProxmoxVMCreator } type ProxmoxVMCreator interface {