apply gofmt

This commit is contained in:
Michael Kuzmin 2018-11-01 00:42:24 +03:00
parent 6bfb34e0ab
commit a3f0f15ffd
35 changed files with 124 additions and 129 deletions

View File

@ -2,11 +2,11 @@ package clone
import (
packerCommon "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/jetbrains-infra/packer-builder-vsphere/common"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/helper/communicator"
)
type Builder struct {
@ -51,7 +51,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
if b.config.Comm.Type != "none" {
steps = append(steps,
&common.StepRun{
Config: &b.config.RunConfig,
Config: &b.config.RunConfig,
SetOrder: false,
},
&common.StepWaitForIp{},

View File

@ -2,12 +2,11 @@ package clone
import (
builderT "github.com/hashicorp/packer/helper/builder/testing"
"github.com/hashicorp/packer/packer"
"github.com/jetbrains-infra/packer-builder-vsphere/common"
commonT "github.com/jetbrains-infra/packer-builder-vsphere/common/testing"
"os"
"github.com/hashicorp/packer/packer"
"testing"
"github.com/jetbrains-infra/packer-builder-vsphere/common"
)
func TestCloneBuilderAcc_default(t *testing.T) {
@ -429,7 +428,7 @@ func TestCloneBuilderAcc_sshPassword(t *testing.T) {
builderT.Test(t, builderT.TestCase{
Builder: &Builder{},
Template: sshPasswordConfig(),
Check: checkDefaultBootOrder(t),
Check: checkDefaultBootOrder(t),
})
}

View File

@ -3,10 +3,10 @@ package clone
import (
packerCommon "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/helper/config"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"github.com/jetbrains-infra/packer-builder-vsphere/common"
"github.com/hashicorp/packer/helper/config"
)
type Config struct {
@ -18,9 +18,9 @@ type Config struct {
common.HardwareConfig `mapstructure:",squash"`
common.ConfigParamsConfig `mapstructure:",squash"`
common.RunConfig `mapstructure:",squash"`
Comm communicator.Config `mapstructure:",squash"`
common.ShutdownConfig `mapstructure:",squash"`
common.RunConfig `mapstructure:",squash"`
Comm communicator.Config `mapstructure:",squash"`
common.ShutdownConfig `mapstructure:",squash"`
CreateSnapshot bool `mapstructure:"create_snapshot"`
ConvertToTemplate bool `mapstructure:"convert_to_template"`

View File

@ -25,7 +25,7 @@ func TestCloneConfig_Timeout(t *testing.T) {
raw["shutdown_timeout"] = "3m"
conf, warns, err := NewConfig(raw)
testConfigOk(t, warns, err)
if conf.ShutdownConfig.Timeout != 3 * time.Minute {
if conf.ShutdownConfig.Timeout != 3*time.Minute {
t.Fatalf("shutdown_timeout sould be equal 3 minutes, got %v", conf.ShutdownConfig.Timeout)
}
}
@ -41,13 +41,13 @@ func TestCloneConfig_RAMReservation(t *testing.T) {
func minimalConfig() map[string]interface{} {
return map[string]interface{}{
"vcenter_server": "vcenter.domain.local",
"username": "root",
"password": "vmware",
"template": "ubuntu",
"vm_name": "vm1",
"host": "esxi1.domain.local",
"ssh_username": "root",
"ssh_password": "secret",
"username": "root",
"password": "vmware",
"template": "ubuntu",
"vm_name": "vm1",
"host": "esxi1.domain.local",
"ssh_username": "root",
"ssh_password": "secret",
}
}

View File

@ -1,12 +1,12 @@
package clone
import (
"context"
"fmt"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"fmt"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"github.com/jetbrains-infra/packer-builder-vsphere/common"
"context"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
)
type CloneConfig struct {

View File

@ -2,12 +2,11 @@ package common
import (
"fmt"
"io/ioutil"
packerssh "github.com/hashicorp/packer/communicator/ssh"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/helper/multistep"
"golang.org/x/crypto/ssh"
"github.com/hashicorp/packer/helper/communicator"
"io/ioutil"
)
func CommHost(state multistep.StateBag) (string, error) {

View File

@ -1,11 +1,11 @@
package common
import (
"context"
"fmt"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"github.com/hashicorp/packer/helper/multistep"
"fmt"
"context"
)
type ConfigParamsConfig struct {

View File

@ -1,10 +1,10 @@
package common
import (
"github.com/hashicorp/packer/helper/multistep"
"fmt"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"context"
"fmt"
"github.com/hashicorp/packer/helper/multistep"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
)
type ConnectConfig struct {

View File

@ -1,25 +1,25 @@
package common
import (
"github.com/hashicorp/packer/packer"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"github.com/hashicorp/packer/helper/multistep"
"context"
"fmt"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
)
type HardwareConfig struct {
CPUs int32 `mapstructure:"CPUs"`
CPUReservation int64 `mapstructure:"CPU_reservation"`
CPULimit int64 `mapstructure:"CPU_limit"`
CpuHotAddEnabled bool `mapstructure:"CPU_hot_plug"`
CPUs int32 `mapstructure:"CPUs"`
CPUReservation int64 `mapstructure:"CPU_reservation"`
CPULimit int64 `mapstructure:"CPU_limit"`
CpuHotAddEnabled bool `mapstructure:"CPU_hot_plug"`
RAM int64 `mapstructure:"RAM"`
RAMReservation int64 `mapstructure:"RAM_reservation"`
RAMReserveAll bool `mapstructure:"RAM_reserve_all"`
MemoryHotAddEnabled bool `mapstructure:"RAM_hot_plug"`
NestedHV bool `mapstructure:"NestedHV"`
NestedHV bool `mapstructure:"NestedHV"`
}
func (c *HardwareConfig) Prepare() []error {

View File

@ -1,11 +1,11 @@
package common
import (
"context"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"strings"
"context"
)
type RunConfig struct {
@ -13,7 +13,7 @@ type RunConfig struct {
}
type StepRun struct {
Config *RunConfig
Config *RunConfig
SetOrder bool
}
@ -41,7 +41,7 @@ func (s *StepRun) Run(_ context.Context, state multistep.StateBag) multistep.Ste
ui.Say("Power on VM...")
err := vm.PowerOn()
if err != nil {
state.Put("error",err)
state.Put("error", err)
return multistep.ActionHalt
}

View File

@ -1,21 +1,21 @@
package common
import (
"bytes"
"context"
"fmt"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"fmt"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"log"
"time"
"bytes"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"context"
)
type ShutdownConfig struct {
Command string `mapstructure:"shutdown_command"`
RawTimeout string `mapstructure:"shutdown_timeout"`
Timeout time.Duration
Timeout time.Duration
}
func (c *ShutdownConfig) Prepare() []error {

View File

@ -1,13 +1,13 @@
package common
import (
"context"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"context"
)
type StepCreateSnapshot struct{
type StepCreateSnapshot struct {
CreateSnapshot bool
}

View File

@ -1,13 +1,13 @@
package common
import (
"context"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"context"
)
type StepConvertToTemplate struct{
type StepConvertToTemplate struct {
ConvertToTemplate bool
}

View File

@ -1,12 +1,12 @@
package common
import (
"github.com/hashicorp/packer/helper/multistep"
"context"
"fmt"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"time"
"context"
)
type StepWaitForIp struct{}

View File

@ -1,14 +1,14 @@
package testing
import (
"fmt"
"math/rand"
"time"
"encoding/json"
"fmt"
"github.com/hashicorp/packer/packer"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"testing"
"github.com/jetbrains-infra/packer-builder-vsphere/common"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"math/rand"
"testing"
"time"
)
func NewVMName() string {
@ -32,7 +32,6 @@ func RenderConfig(config map[string]interface{}) string {
return string(j)
}
func TestConn(t *testing.T) *driver.Driver {
d, err := driver.NewDriver(&driver.ConnectConfig{
VCenterServer: "vcenter.vsphere65.test",
@ -57,4 +56,3 @@ func GetVM(t *testing.T, d *driver.Driver, artifacts []packer.Artifact) *driver.
return vm
}

View File

@ -1,11 +1,11 @@
package driver
import (
"fmt"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/types"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/soap"
"fmt"
"github.com/vmware/govmomi/vim25/types"
)
type Datastore struct {

View File

@ -1,16 +1,16 @@
package driver
import (
"context"
"fmt"
"github.com/vmware/govmomi"
"github.com/vmware/govmomi/find"
"context"
"net/url"
"fmt"
"github.com/vmware/govmomi/object"
"time"
"github.com/vmware/govmomi/session"
"github.com/vmware/govmomi/vim25/soap"
"github.com/vmware/govmomi/vim25"
"github.com/vmware/govmomi/vim25/soap"
"net/url"
"time"
)
type Driver struct {

View File

@ -2,10 +2,10 @@ package driver
import (
"fmt"
"math/rand"
"os"
"testing"
"time"
"math/rand"
)
// Defines whether acceptance tests should be run

View File

@ -1,10 +1,10 @@
package driver
import (
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/types"
"github.com/vmware/govmomi/vim25/mo"
"fmt"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/types"
)
type Folder struct {

View File

@ -2,18 +2,18 @@ package driver
import (
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/types"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/types"
)
type Host struct {
driver *Driver
host *object.HostSystem
host *object.HostSystem
}
func (d *Driver) NewHost(ref *types.ManagedObjectReference) *Host {
return &Host{
host: object.NewHostSystem(d.client.Client, *ref),
host: object.NewHostSystem(d.client.Client, *ref),
driver: d,
}
}
@ -29,7 +29,7 @@ func (d *Driver) FindHost(name string) (*Host, error) {
}, nil
}
func (h *Host) Info(params ...string) (*mo.HostSystem, error){
func (h *Host) Info(params ...string) (*mo.HostSystem, error) {
var p []string
if len(params) == 0 {
p = []string{"*"}

View File

@ -1,10 +1,10 @@
package driver
import (
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/types"
"github.com/vmware/govmomi/vim25/mo"
"fmt"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/types"
)
type ResourcePool struct {
@ -32,7 +32,7 @@ func (d *Driver) FindResourcePool(cluster string, host string, name string) (*Re
return nil, err
}
return &ResourcePool{
pool: p,
pool: p,
driver: d,
}, nil
}

View File

@ -4,7 +4,7 @@ import "testing"
func TestResourcePoolAcc(t *testing.T) {
d := newTestDriver(t)
p, err := d.FindResourcePool("","esxi-1.vsphere65.test", "pool1/pool2")
p, err := d.FindResourcePool("", "esxi-1.vsphere65.test", "pool1/pool2")
if err != nil {
t.Fatalf("Cannot find the default resource pool '%v': %v", "pool1/pool2", err)
}

View File

@ -1,14 +1,14 @@
package driver
import (
"context"
"errors"
"fmt"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/types"
"time"
"strings"
"context"
"time"
)
type VirtualMachine struct {
@ -54,7 +54,7 @@ type CreateConfig struct {
Network string // "" for default network
NetworkCard string // example: vmxnet3
USBController bool
Version uint // example: 10
Version uint // example: 10
Firmware string // efi or bios
}

View File

@ -1,8 +1,8 @@
package driver
import (
"github.com/vmware/govmomi/vim25/types"
"errors"
"github.com/vmware/govmomi/vim25/types"
)
func (vm *VirtualMachine) AddSATAController() error {

View File

@ -1,11 +1,11 @@
package driver
import (
"context"
"log"
"net"
"testing"
"time"
"context"
)
func TestVMAcc_clone(t *testing.T) {
@ -168,7 +168,7 @@ func configureCheck(t *testing.T, vm *VirtualMachine, _ *CloneConfig) {
func configureRAMReserveAllCheck(t *testing.T, vm *VirtualMachine, _ *CloneConfig) {
log.Printf("[DEBUG] Configuring the vm")
vm.Configure(&HardwareConfig{ RAMReserveAll: true })
vm.Configure(&HardwareConfig{RAMReserveAll: true})
log.Printf("[DEBUG] Running checks")
vmInfo, err := vm.Info("config")
@ -237,7 +237,7 @@ func startAndStopCheck(t *testing.T, vm *VirtualMachine, config *CloneConfig) {
vm.StartShutdown()
log.Printf("[DEBUG] Waiting max 1m0s for shutdown to complete")
vm.WaitForShutdown(context.TODO(), 1 * time.Minute)
vm.WaitForShutdown(context.TODO(), 1*time.Minute)
}
func snapshotCheck(t *testing.T, vm *VirtualMachine, config *CloneConfig) {

View File

@ -1,11 +1,11 @@
package driver
import (
"github.com/vmware/govmomi/vim25/methods"
"github.com/vmware/govmomi/vim25/types"
"golang.org/x/mobile/event/key"
"strings"
"unicode"
"github.com/vmware/govmomi/vim25/types"
"github.com/vmware/govmomi/vim25/methods"
"golang.org/x/mobile/event/key"
)
type KeyInput struct {
@ -26,9 +26,9 @@ func init() {
scancodeIndex["!@#$%^&*()"] = key.Code1
scancodeIndex[" "] = key.CodeSpacebar
scancodeIndex["-=[]\\"] = key.CodeHyphenMinus
scancodeIndex["_+{}|" ] = key.CodeHyphenMinus
scancodeIndex[ ";'`,./" ] = key.CodeSemicolon
scancodeIndex[":\"~<>?" ] = key.CodeSemicolon
scancodeIndex["_+{}|"] = key.CodeHyphenMinus
scancodeIndex[";'`,./"] = key.CodeSemicolon
scancodeIndex[":\"~<>?"] = key.CodeSemicolon
for chars, start := range scancodeIndex {
for i, r := range chars {

View File

@ -1,13 +1,12 @@
package main
import (
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"fmt"
"context"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
)
func main() {
d, err := driver.NewDriver(context.TODO(), &driver.ConnectConfig{
d, err := driver.NewDriver(&driver.ConnectConfig{
VCenterServer: "vcenter.vsphere65.test",
Username: "root",
Password: "jetbrains",

View File

@ -2,11 +2,11 @@ package iso
import (
packerCommon "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/jetbrains-infra/packer-builder-vsphere/common"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/helper/communicator"
)
type Builder struct {
@ -63,7 +63,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
Host: b.config.Host,
},
&common.StepRun{
Config: &b.config.RunConfig,
Config: &b.config.RunConfig,
SetOrder: true,
},
&StepBootCommand{

View File

@ -3,10 +3,10 @@ package iso
import (
packerCommon "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/communicator"
"github.com/hashicorp/packer/helper/config"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/template/interpolate"
"github.com/jetbrains-infra/packer-builder-vsphere/common"
"github.com/hashicorp/packer/helper/config"
)
type Config struct {
@ -18,12 +18,12 @@ type Config struct {
common.HardwareConfig `mapstructure:",squash"`
common.ConfigParamsConfig `mapstructure:",squash"`
CDRomConfig `mapstructure:",squash"`
FloppyConfig `mapstructure:",squash"`
common.RunConfig `mapstructure:",squash"`
BootConfig `mapstructure:",squash"`
Comm communicator.Config `mapstructure:",squash"`
common.ShutdownConfig `mapstructure:",squash"`
CDRomConfig `mapstructure:",squash"`
FloppyConfig `mapstructure:",squash"`
common.RunConfig `mapstructure:",squash"`
BootConfig `mapstructure:",squash"`
Comm communicator.Config `mapstructure:",squash"`
common.ShutdownConfig `mapstructure:",squash"`
CreateSnapshot bool `mapstructure:"create_snapshot"`
ConvertToTemplate bool `mapstructure:"convert_to_template"`

View File

@ -1,16 +1,16 @@
package iso
import (
"context"
"fmt"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"github.com/hashicorp/packer/helper/multistep"
"fmt"
"context"
)
type CDRomConfig struct {
CdromType string `mapstructure:"cdrom_type"`
ISOPaths []string `mapstructure:"iso_paths"`
CdromType string `mapstructure:"cdrom_type"`
ISOPaths []string `mapstructure:"iso_paths"`
}
type StepAddCDRom struct {
@ -20,7 +20,7 @@ type StepAddCDRom struct {
func (c *CDRomConfig) Prepare() []error {
var errs []error
if (c.CdromType != "" && c.CdromType != "ide" && c.CdromType != "sata") {
if c.CdromType != "" && c.CdromType != "ide" && c.CdromType != "sata" {
errs = append(errs, fmt.Errorf("'cdrom_type' must be 'ide' or 'sata'"))
}

View File

@ -1,11 +1,11 @@
package iso
import (
"context"
"fmt"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"fmt"
"context"
)
type FloppyConfig struct {

View File

@ -1,18 +1,18 @@
package iso
import (
"context"
"fmt"
"github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"github.com/hashicorp/packer/helper/multistep"
"fmt"
"time"
"strings"
"golang.org/x/mobile/event/key"
"unicode/utf8"
"github.com/hashicorp/packer/common"
"os"
"log"
"context"
"os"
"strings"
"time"
"unicode/utf8"
)
type BootConfig struct {

View File

@ -1,12 +1,12 @@
package iso
import (
"context"
"fmt"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/jetbrains-infra/packer-builder-vsphere/common"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"github.com/hashicorp/packer/helper/multistep"
"context"
)
type CreateConfig struct {
@ -34,7 +34,7 @@ func (c *CreateConfig) Prepare() []error {
c.GuestOSType = "otherGuest"
}
if (c.Firmware != "" && c.Firmware != "bios" && c.Firmware != "efi") {
if c.Firmware != "" && c.Firmware != "bios" && c.Firmware != "efi" {
errs = append(errs, fmt.Errorf("'firmware' must be 'bios' or 'efi'"))
}

View File

@ -1,10 +1,10 @@
package iso
import (
"context"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"github.com/hashicorp/packer/helper/multistep"
"context"
)
type StepRemoveCDRom struct{}

View File

@ -1,11 +1,11 @@
package iso
import (
"context"
"github.com/hashicorp/packer/helper/multistep"
"github.com/hashicorp/packer/packer"
"github.com/jetbrains-infra/packer-builder-vsphere/driver"
"github.com/hashicorp/packer/helper/multistep"
"github.com/vmware/govmomi/vim25/types"
"context"
)
type StepRemoveFloppy struct {