run gofmt
This commit is contained in:
parent
32c0fef4c1
commit
d920b3fbf4
|
@ -86,11 +86,11 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
|
|||
|
||||
if len(b.config.ChrootMounts) == 0 {
|
||||
b.config.ChrootMounts = [][]string{
|
||||
[]string{"proc", "proc", "/proc"},
|
||||
[]string{"sysfs", "sysfs", "/sys"},
|
||||
[]string{"bind", "/dev", "/dev"},
|
||||
[]string{"devpts", "devpts", "/dev/pts"},
|
||||
[]string{"binfmt_misc", "binfmt_misc", "/proc/sys/fs/binfmt_misc"},
|
||||
{"proc", "proc", "/proc"},
|
||||
{"sysfs", "sysfs", "/sys"},
|
||||
{"bind", "/dev", "/dev"},
|
||||
{"devpts", "devpts", "/dev/pts"},
|
||||
{"binfmt_misc", "binfmt_misc", "/proc/sys/fs/binfmt_misc"},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ func TestBuilderPrepare_ChrootMounts(t *testing.T) {
|
|||
}
|
||||
|
||||
config["chroot_mounts"] = [][]string{
|
||||
[]string{"bad"},
|
||||
{"bad"},
|
||||
}
|
||||
warnings, err = b.Prepare(config)
|
||||
if len(warnings) > 0 {
|
||||
|
|
|
@ -21,7 +21,7 @@ func (s *StepDeregisterAMI) Run(state multistep.StateBag) multistep.StepAction {
|
|||
// check for force deregister
|
||||
if s.ForceDeregister {
|
||||
resp, err := ec2conn.DescribeImages(&ec2.DescribeImagesInput{
|
||||
Filters: []*ec2.Filter{&ec2.Filter{
|
||||
Filters: []*ec2.Filter{{
|
||||
Name: aws.String("name"),
|
||||
Values: []*string{aws.String(s.AMIName)},
|
||||
}}})
|
||||
|
|
|
@ -28,7 +28,7 @@ func (s *StepPreValidate) Run(state multistep.StateBag) multistep.StepAction {
|
|||
|
||||
ui.Say("Prevalidating AMI Name...")
|
||||
resp, err := ec2conn.DescribeImages(&ec2.DescribeImagesInput{
|
||||
Filters: []*ec2.Filter{&ec2.Filter{
|
||||
Filters: []*ec2.Filter{{
|
||||
Name: aws.String("name"),
|
||||
Values: []*string{aws.String(s.DestAmiName)},
|
||||
}}})
|
||||
|
|
|
@ -171,7 +171,7 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
|
|||
|
||||
if s.SubnetId != "" && s.AssociatePublicIpAddress {
|
||||
runOpts.NetworkInterfaces = []*ec2.InstanceNetworkInterfaceSpecification{
|
||||
&ec2.InstanceNetworkInterfaceSpecification{
|
||||
{
|
||||
DeviceIndex: aws.Int64(0),
|
||||
AssociatePublicIpAddress: &s.AssociatePublicIpAddress,
|
||||
SubnetId: &s.SubnetId,
|
||||
|
@ -207,7 +207,7 @@ func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepActi
|
|||
UserData: &userData,
|
||||
IamInstanceProfile: &ec2.IamInstanceProfileSpecification{Name: &s.IamInstanceProfile},
|
||||
NetworkInterfaces: []*ec2.InstanceNetworkInterfaceSpecification{
|
||||
&ec2.InstanceNetworkInterfaceSpecification{
|
||||
{
|
||||
DeviceIndex: aws.Int64(0),
|
||||
AssociatePublicIpAddress: &s.AssociatePublicIpAddress,
|
||||
SubnetId: &s.SubnetId,
|
||||
|
|
|
@ -138,7 +138,7 @@ func checkRegionCopy(regions []string) builderT.TestCheckFunc {
|
|||
for _, r := range regions {
|
||||
regionSet[r] = struct{}{}
|
||||
}
|
||||
for r, _ := range artifact.Amis {
|
||||
for r := range artifact.Amis {
|
||||
if _, ok := regionSet[r]; !ok {
|
||||
return fmt.Errorf("unknown region: %s", r)
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ func (s *stepCleanupVolumes) Cleanup(state multistep.StateBag) {
|
|||
// date information on them
|
||||
resp, err := ec2conn.DescribeVolumes(&ec2.DescribeVolumesInput{
|
||||
Filters: []*ec2.Filter{
|
||||
&ec2.Filter{
|
||||
{
|
||||
Name: aws.String("volume-id"),
|
||||
Values: vl,
|
||||
},
|
||||
|
@ -92,7 +92,7 @@ func (s *stepCleanupVolumes) Cleanup(state multistep.StateBag) {
|
|||
}
|
||||
|
||||
// Filter out any devices marked for saving
|
||||
for saveName, _ := range save {
|
||||
for saveName := range save {
|
||||
for volKey, volName := range volList {
|
||||
if volName == saveName {
|
||||
delete(volList, volKey)
|
||||
|
@ -101,7 +101,7 @@ func (s *stepCleanupVolumes) Cleanup(state multistep.StateBag) {
|
|||
}
|
||||
|
||||
// Destroy remaining volumes
|
||||
for k, _ := range volList {
|
||||
for k := range volList {
|
||||
ui.Say(fmt.Sprintf("Destroying volume (%s)...", k))
|
||||
_, err := ec2conn.DeleteVolume(&ec2.DeleteVolumeInput{VolumeId: aws.String(k)})
|
||||
if err != nil {
|
||||
|
|
|
@ -41,7 +41,7 @@ func (s *stepCreateDroplet) Run(state multistep.StateBag) multistep.StepAction {
|
|||
Slug: c.Image,
|
||||
},
|
||||
SSHKeys: []godo.DropletCreateSSHKey{
|
||||
godo.DropletCreateSSHKey{ID: int(sshKeyId)},
|
||||
{ID: int(sshKeyId)},
|
||||
},
|
||||
PrivateNetworking: c.PrivateNetworking,
|
||||
UserData: userData,
|
||||
|
|
|
@ -347,7 +347,7 @@ func (d *driverGCE) RunInstance(c *InstanceConfig) (<-chan error, error) {
|
|||
instance := compute.Instance{
|
||||
Description: c.Description,
|
||||
Disks: []*compute.AttachedDisk{
|
||||
&compute.AttachedDisk{
|
||||
{
|
||||
Type: "PERSISTENT",
|
||||
Mode: "READ_WRITE",
|
||||
Kind: "compute#attachedDisk",
|
||||
|
@ -366,7 +366,7 @@ func (d *driverGCE) RunInstance(c *InstanceConfig) (<-chan error, error) {
|
|||
},
|
||||
Name: c.Name,
|
||||
NetworkInterfaces: []*compute.NetworkInterface{
|
||||
&compute.NetworkInterface{
|
||||
{
|
||||
AccessConfigs: []*compute.AccessConfig{accessconfig},
|
||||
Network: network.SelfLink,
|
||||
Subnetwork: subnetworkSelfLink,
|
||||
|
@ -376,7 +376,7 @@ func (d *driverGCE) RunInstance(c *InstanceConfig) (<-chan error, error) {
|
|||
Preemptible: c.Preemptible,
|
||||
},
|
||||
ServiceAccounts: []*compute.ServiceAccount{
|
||||
&compute.ServiceAccount{
|
||||
{
|
||||
Email: c.ServiceAccountEmail,
|
||||
Scopes: c.Scopes,
|
||||
},
|
||||
|
|
|
@ -28,7 +28,7 @@ func TestPrlctlConfigPrepare_Prlctl(t *testing.T) {
|
|||
}
|
||||
|
||||
expected := [][]string{
|
||||
[]string{"foo", "bar", "baz"},
|
||||
{"foo", "bar", "baz"},
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(c.Prlctl, expected) {
|
||||
|
|
|
@ -28,7 +28,7 @@ func TestPrlctlPostConfigPrepare_PrlctlPost(t *testing.T) {
|
|||
}
|
||||
|
||||
expected := [][]string{
|
||||
[]string{"foo", "bar", "baz"},
|
||||
{"foo", "bar", "baz"},
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(c.PrlctlPost, expected) {
|
||||
|
|
|
@ -46,16 +46,16 @@ func TestStepTypeBootCommand(t *testing.T) {
|
|||
|
||||
// Verify
|
||||
var expected = [][]string{
|
||||
[]string{"02", "82", "03", "83", "04", "84", "05", "85", "06", "86", "07", "87", "08", "88", "09", "89", "0a", "8a", "0b", "8b", "0c", "8c", "0d", "8d", "1c", "9c"},
|
||||
[]string{},
|
||||
[]string{"2a", "02", "82", "aa", "2a", "03", "83", "aa", "2a", "04", "84", "aa", "2a", "05", "85", "aa", "2a", "06", "86", "aa", "2a", "07", "87", "aa", "2a", "08", "88", "aa", "2a", "09", "89", "aa", "2a", "0a", "8a", "aa", "2a", "0b", "8b", "aa", "2a", "0c", "8c", "aa", "2a", "0d", "8d", "aa", "1c", "9c"},
|
||||
[]string{"10", "90", "11", "91", "12", "92", "13", "93", "14", "94", "15", "95", "16", "96", "17", "97", "18", "98", "19", "99", "1a", "9a", "1b", "9b", "1c", "9c"},
|
||||
[]string{"2a", "10", "90", "aa", "2a", "11", "91", "aa", "2a", "12", "92", "aa", "2a", "13", "93", "aa", "2a", "14", "94", "aa", "2a", "15", "95", "aa", "2a", "16", "96", "aa", "2a", "17", "97", "aa", "2a", "18", "98", "aa", "2a", "19", "99", "aa", "2a", "1a", "9a", "aa", "2a", "1b", "9b", "aa", "1c", "9c"},
|
||||
[]string{"1e", "9e", "1f", "9f", "20", "a0", "21", "a1", "22", "a2", "23", "a3", "24", "a4", "25", "a5", "26", "a6", "27", "a7", "28", "a8", "29", "a9", "1c", "9c"},
|
||||
[]string{"2a", "1e", "9e", "aa", "2a", "1f", "9f", "aa", "2a", "20", "a0", "aa", "2a", "21", "a1", "aa", "2a", "22", "a2", "aa", "2a", "23", "a3", "aa", "2a", "24", "a4", "aa", "2a", "25", "a5", "aa", "2a", "26", "a6", "aa", "2a", "27", "a7", "aa", "2a", "28", "a8", "aa", "2a", "29", "a9", "aa", "1c", "9c"},
|
||||
[]string{"2b", "ab", "2c", "ac", "2d", "ad", "2e", "ae", "2f", "af", "30", "b0", "31", "b1", "32", "b2", "33", "b3", "34", "b4", "35", "b5", "1c", "9c"},
|
||||
[]string{"2a", "2b", "ab", "aa", "2a", "2c", "ac", "aa", "2a", "2d", "ad", "aa", "2a", "2e", "ae", "aa", "2a", "2f", "af", "aa", "2a", "30", "b0", "aa", "2a", "31", "b1", "aa", "2a", "32", "b2", "aa", "2a", "33", "b3", "aa", "2a", "34", "b4", "aa", "2a", "35", "b5", "aa", "1c", "9c"},
|
||||
[]string{"39", "b9", "1c", "9c"},
|
||||
{"02", "82", "03", "83", "04", "84", "05", "85", "06", "86", "07", "87", "08", "88", "09", "89", "0a", "8a", "0b", "8b", "0c", "8c", "0d", "8d", "1c", "9c"},
|
||||
{},
|
||||
{"2a", "02", "82", "aa", "2a", "03", "83", "aa", "2a", "04", "84", "aa", "2a", "05", "85", "aa", "2a", "06", "86", "aa", "2a", "07", "87", "aa", "2a", "08", "88", "aa", "2a", "09", "89", "aa", "2a", "0a", "8a", "aa", "2a", "0b", "8b", "aa", "2a", "0c", "8c", "aa", "2a", "0d", "8d", "aa", "1c", "9c"},
|
||||
{"10", "90", "11", "91", "12", "92", "13", "93", "14", "94", "15", "95", "16", "96", "17", "97", "18", "98", "19", "99", "1a", "9a", "1b", "9b", "1c", "9c"},
|
||||
{"2a", "10", "90", "aa", "2a", "11", "91", "aa", "2a", "12", "92", "aa", "2a", "13", "93", "aa", "2a", "14", "94", "aa", "2a", "15", "95", "aa", "2a", "16", "96", "aa", "2a", "17", "97", "aa", "2a", "18", "98", "aa", "2a", "19", "99", "aa", "2a", "1a", "9a", "aa", "2a", "1b", "9b", "aa", "1c", "9c"},
|
||||
{"1e", "9e", "1f", "9f", "20", "a0", "21", "a1", "22", "a2", "23", "a3", "24", "a4", "25", "a5", "26", "a6", "27", "a7", "28", "a8", "29", "a9", "1c", "9c"},
|
||||
{"2a", "1e", "9e", "aa", "2a", "1f", "9f", "aa", "2a", "20", "a0", "aa", "2a", "21", "a1", "aa", "2a", "22", "a2", "aa", "2a", "23", "a3", "aa", "2a", "24", "a4", "aa", "2a", "25", "a5", "aa", "2a", "26", "a6", "aa", "2a", "27", "a7", "aa", "2a", "28", "a8", "aa", "2a", "29", "a9", "aa", "1c", "9c"},
|
||||
{"2b", "ab", "2c", "ac", "2d", "ad", "2e", "ae", "2f", "af", "30", "b0", "31", "b1", "32", "b2", "33", "b3", "34", "b4", "35", "b5", "1c", "9c"},
|
||||
{"2a", "2b", "ab", "aa", "2a", "2c", "ac", "aa", "2a", "2d", "ad", "aa", "2a", "2e", "ae", "aa", "2a", "2f", "af", "aa", "2a", "30", "b0", "aa", "2a", "31", "b1", "aa", "2a", "32", "b2", "aa", "2a", "33", "b3", "aa", "2a", "34", "b4", "aa", "2a", "35", "b5", "aa", "1c", "9c"},
|
||||
{"39", "b9", "1c", "9c"},
|
||||
}
|
||||
fail := false
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@ import (
|
|||
|
||||
func testConfig() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"image": "Ubuntu-16.04",
|
||||
"password": "password",
|
||||
"username": "username",
|
||||
"image": "Ubuntu-16.04",
|
||||
"password": "password",
|
||||
"username": "username",
|
||||
"snapshot_name": "packer",
|
||||
"type": "profitbricks",
|
||||
"type": "profitbricks",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ func (s *stepCreateServer) Run(state multistep.StateBag) multistep.StepAction {
|
|||
if datacenter.StatusCode > 299 {
|
||||
var restError RestError
|
||||
json.Unmarshal([]byte(datacenter.Response), &restError)
|
||||
if ( len(restError.Messages) > 0) {
|
||||
if len(restError.Messages) > 0 {
|
||||
ui.Error(restError.Messages[0].Message)
|
||||
} else {
|
||||
ui.Error(datacenter.Response)
|
||||
|
@ -169,13 +169,13 @@ func (d *stepCreateServer) checkForErrors(instance profitbricks.Resp) error {
|
|||
}
|
||||
|
||||
type RestError struct {
|
||||
HttpStatus int `json:"httpStatus,omitempty"`
|
||||
Messages []Message`json:"messages,omitempty"`
|
||||
HttpStatus int `json:"httpStatus,omitempty"`
|
||||
Messages []Message `json:"messages,omitempty"`
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
ErrorCode string `json:"errorCode,omitempty"`
|
||||
Message string`json:"message,omitempty"`
|
||||
Message string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
func (d *stepCreateServer) getImageId(imageName string, c *Config) string {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package profitbricks
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/mitchellh/multistep"
|
||||
"github.com/mitchellh/packer/packer"
|
||||
"github.com/profitbricks/profitbricks-sdk-go"
|
||||
"time"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type stepTakeSnapshot struct{}
|
||||
|
@ -30,7 +30,7 @@ func (s *stepTakeSnapshot) Run(state multistep.StateBag) multistep.StepAction {
|
|||
if snapshot.StatusCode > 299 {
|
||||
var restError RestError
|
||||
json.Unmarshal([]byte(snapshot.Response), &restError)
|
||||
if ( len(restError.Messages) > 0) {
|
||||
if len(restError.Messages) > 0 {
|
||||
ui.Error(restError.Messages[0].Message)
|
||||
} else {
|
||||
ui.Error(snapshot.Response)
|
||||
|
|
|
@ -21,10 +21,10 @@ import (
|
|||
const BuilderId = "transcend.qemu"
|
||||
|
||||
var accels = map[string]struct{}{
|
||||
"none": struct{}{},
|
||||
"kvm": struct{}{},
|
||||
"tcg": struct{}{},
|
||||
"xen": struct{}{},
|
||||
"none": {},
|
||||
"kvm": {},
|
||||
"tcg": {},
|
||||
"xen": {},
|
||||
}
|
||||
|
||||
var netDevice = map[string]bool{
|
||||
|
|
|
@ -570,7 +570,7 @@ func TestBuilderPrepare_QemuArgs(t *testing.T) {
|
|||
|
||||
// Test with a good one
|
||||
config["qemuargs"] = [][]interface{}{
|
||||
[]interface{}{"foo", "bar", "baz"},
|
||||
{"foo", "bar", "baz"},
|
||||
}
|
||||
|
||||
b = Builder{}
|
||||
|
@ -583,7 +583,7 @@ func TestBuilderPrepare_QemuArgs(t *testing.T) {
|
|||
}
|
||||
|
||||
expected := [][]string{
|
||||
[]string{"foo", "bar", "baz"},
|
||||
{"foo", "bar", "baz"},
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(b.config.QemuArgs, expected) {
|
||||
|
|
|
@ -28,7 +28,7 @@ func TestVBoxManageConfigPrepare_VBoxManage(t *testing.T) {
|
|||
}
|
||||
|
||||
expected := [][]string{
|
||||
[]string{"foo", "bar", "baz"},
|
||||
{"foo", "bar", "baz"},
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(c.VBoxManage, expected) {
|
||||
|
|
|
@ -28,7 +28,7 @@ func TestVBoxManagePostConfigPrepare_VBoxManage(t *testing.T) {
|
|||
}
|
||||
|
||||
expected := [][]string{
|
||||
[]string{"foo", "bar", "baz"},
|
||||
{"foo", "bar", "baz"},
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(c.VBoxManagePost, expected) {
|
||||
|
|
|
@ -35,7 +35,7 @@ func (s StepCleanVMX) Run(state multistep.StateBag) multistep.StepAction {
|
|||
|
||||
// Delete the floppy0 entries so the floppy is no longer mounted
|
||||
ui.Message("Unmounting floppy from VMX...")
|
||||
for k, _ := range vmxData {
|
||||
for k := range vmxData {
|
||||
if strings.HasPrefix(k, "floppy0.") {
|
||||
log.Printf("Deleting key: %s", k)
|
||||
delete(vmxData, k)
|
||||
|
|
|
@ -44,7 +44,7 @@ func (s *StepConfigureVMX) Run(state multistep.StateBag) multistep.StepAction {
|
|||
// Delete any generated addresses since we want to regenerate
|
||||
// them. Conflicting MAC addresses is a bad time.
|
||||
addrRegex := regexp.MustCompile(`(?i)^ethernet\d+\.generatedAddress`)
|
||||
for k, _ := range vmxData {
|
||||
for k := range vmxData {
|
||||
if addrRegex.MatchString(k) {
|
||||
delete(vmxData, k)
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ func EncodeVMX(contents map[string]string) string {
|
|||
|
||||
i := 0
|
||||
keys := make([]string, len(contents))
|
||||
for k, _ := range contents {
|
||||
for k := range contents {
|
||||
keys[i] = k
|
||||
i++
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ func (s *stepCreateVMX) Run(state multistep.StateBag) multistep.StepAction {
|
|||
ctx := config.ctx
|
||||
|
||||
if len(config.AdditionalDiskSize) > 0 {
|
||||
for i, _ := range config.AdditionalDiskSize {
|
||||
for i := range config.AdditionalDiskSize {
|
||||
ctx.Data = &additionalDiskTemplateData{
|
||||
DiskNumber: i + 1,
|
||||
DiskName: config.DiskName,
|
||||
|
|
|
@ -66,7 +66,7 @@ func (c *InspectCommand) Run(args []string) int {
|
|||
ui.Say("Optional variables and their defaults:\n")
|
||||
keys := make([]string, 0, len(tpl.Variables))
|
||||
max := 0
|
||||
for k, _ := range tpl.Variables {
|
||||
for k := range tpl.Variables {
|
||||
keys = append(keys, k)
|
||||
if len(k) > max {
|
||||
max = len(k)
|
||||
|
@ -98,7 +98,7 @@ func (c *InspectCommand) Run(args []string) int {
|
|||
} else {
|
||||
keys := make([]string, 0, len(tpl.Builders))
|
||||
max := 0
|
||||
for k, _ := range tpl.Builders {
|
||||
for k := range tpl.Builders {
|
||||
keys = append(keys, k)
|
||||
if len(k) > max {
|
||||
max = len(k)
|
||||
|
|
|
@ -60,7 +60,7 @@ func TestPush(t *testing.T) {
|
|||
}
|
||||
|
||||
expectedBuilds := map[string]*uploadBuildInfo{
|
||||
"dummy": &uploadBuildInfo{
|
||||
"dummy": {
|
||||
Type: "dummy",
|
||||
},
|
||||
}
|
||||
|
@ -91,11 +91,11 @@ func TestPush_builds(t *testing.T) {
|
|||
}
|
||||
|
||||
expectedBuilds := map[string]*uploadBuildInfo{
|
||||
"dummy": &uploadBuildInfo{
|
||||
"dummy": {
|
||||
Type: "dummy",
|
||||
Artifact: true,
|
||||
},
|
||||
"foo": &uploadBuildInfo{
|
||||
"foo": {
|
||||
Type: "dummy",
|
||||
},
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ func (d *DownloadClient) Get() (string, error) {
|
|||
|
||||
// Remove forward slash on absolute Windows file URLs before processing
|
||||
if runtime.GOOS == "windows" && len(finalPath) > 0 && finalPath[0] == '/' {
|
||||
finalPath = finalPath[1:len(finalPath)]
|
||||
finalPath = finalPath[1:]
|
||||
}
|
||||
// Keep track of the source so we can make sure not to delete this later
|
||||
sourcePath = finalPath
|
||||
|
|
|
@ -353,7 +353,7 @@ func fsDirectoryCache(rootDirectory fs.Directory) directoryCache {
|
|||
// directory not cached, so start at the root and walk each component
|
||||
// creating them if they're not in cache
|
||||
var entry fs.Directory
|
||||
for i, _ := range component {
|
||||
for i := range component {
|
||||
|
||||
// join all of our components into a key
|
||||
path := strings.Join(component[:i], "/")
|
||||
|
|
|
@ -76,12 +76,12 @@ func TestStepCreateFloppy(t *testing.T) {
|
|||
|
||||
lists := [][]string{
|
||||
files,
|
||||
[]string{dir + string(os.PathSeparator) + prefix + "*" + ext},
|
||||
[]string{dir + string(os.PathSeparator) + prefix + "?" + ext},
|
||||
[]string{dir + string(os.PathSeparator) + prefix + "[0123456789]" + ext},
|
||||
[]string{dir + string(os.PathSeparator) + prefix + "[0-9]" + ext},
|
||||
[]string{dir + string(os.PathSeparator)},
|
||||
[]string{dir},
|
||||
{dir + string(os.PathSeparator) + prefix + "*" + ext},
|
||||
{dir + string(os.PathSeparator) + prefix + "?" + ext},
|
||||
{dir + string(os.PathSeparator) + prefix + "[0123456789]" + ext},
|
||||
{dir + string(os.PathSeparator) + prefix + "[0-9]" + ext},
|
||||
{dir + string(os.PathSeparator)},
|
||||
{dir},
|
||||
}
|
||||
|
||||
for _, step.Files = range lists {
|
||||
|
@ -177,12 +177,12 @@ func xxxTestStepCreateFloppy_notfound(t *testing.T) {
|
|||
}
|
||||
|
||||
lists := [][]string{
|
||||
[]string{dir + string(os.PathSeparator) + prefix + "*"},
|
||||
[]string{dir + string(os.PathSeparator) + prefix + "?"},
|
||||
[]string{dir + string(os.PathSeparator) + prefix + "[0123456789]"},
|
||||
[]string{dir + string(os.PathSeparator) + prefix + "[0-9]"},
|
||||
[]string{dir + string(os.PathSeparator)},
|
||||
[]string{dir},
|
||||
{dir + string(os.PathSeparator) + prefix + "*"},
|
||||
{dir + string(os.PathSeparator) + prefix + "?"},
|
||||
{dir + string(os.PathSeparator) + prefix + "[0123456789]"},
|
||||
{dir + string(os.PathSeparator) + prefix + "[0-9]"},
|
||||
{dir + string(os.PathSeparator)},
|
||||
{dir},
|
||||
}
|
||||
|
||||
for _, step.Files = range lists {
|
||||
|
@ -225,22 +225,22 @@ func TestStepCreateFloppyDirectories(t *testing.T) {
|
|||
|
||||
// keep in mind that .FilesAdded doesn't keep track of the target filename or directories, but rather the source filename.
|
||||
directories := [][]contentsTest{
|
||||
[]contentsTest{
|
||||
contentsTest{dirs: []string{"file1", "file2", "file3"}, result: []string{"file1", "file2", "file3"}},
|
||||
contentsTest{dirs: []string{"file?"}, result: []string{"file1", "file2", "file3"}},
|
||||
contentsTest{dirs: []string{"*"}, result: []string{"file1", "file2", "file3"}},
|
||||
{
|
||||
{dirs: []string{"file1", "file2", "file3"}, result: []string{"file1", "file2", "file3"}},
|
||||
{dirs: []string{"file?"}, result: []string{"file1", "file2", "file3"}},
|
||||
{dirs: []string{"*"}, result: []string{"file1", "file2", "file3"}},
|
||||
},
|
||||
[]contentsTest{
|
||||
contentsTest{dirs: []string{"dir1"}, result: []string{"dir1/file1", "dir1/file2", "dir1/file3"}},
|
||||
contentsTest{dirs: []string{"dir1/file1", "dir1/file2", "dir1/file3"}, result: []string{"dir1/file1", "dir1/file2", "dir1/file3"}},
|
||||
contentsTest{dirs: []string{"*"}, result: []string{"dir1/file1", "dir1/file2", "dir1/file3"}},
|
||||
contentsTest{dirs: []string{"*/*"}, result: []string{"dir1/file1", "dir1/file2", "dir1/file3"}},
|
||||
{
|
||||
{dirs: []string{"dir1"}, result: []string{"dir1/file1", "dir1/file2", "dir1/file3"}},
|
||||
{dirs: []string{"dir1/file1", "dir1/file2", "dir1/file3"}, result: []string{"dir1/file1", "dir1/file2", "dir1/file3"}},
|
||||
{dirs: []string{"*"}, result: []string{"dir1/file1", "dir1/file2", "dir1/file3"}},
|
||||
{dirs: []string{"*/*"}, result: []string{"dir1/file1", "dir1/file2", "dir1/file3"}},
|
||||
},
|
||||
[]contentsTest{
|
||||
contentsTest{dirs: []string{"dir1"}, result: []string{"dir1/file1", "dir1/subdir1/file1", "dir1/subdir1/file2"}},
|
||||
contentsTest{dirs: []string{"dir2/*"}, result: []string{"dir2/subdir1/file1", "dir2/subdir1/file2"}},
|
||||
contentsTest{dirs: []string{"dir2/subdir1"}, result: []string{"dir2/subdir1/file1", "dir2/subdir1/file2"}},
|
||||
contentsTest{dirs: []string{"dir?"}, result: []string{"dir1/file1", "dir1/subdir1/file1", "dir1/subdir1/file2", "dir2/subdir1/file1", "dir2/subdir1/file2"}},
|
||||
{
|
||||
{dirs: []string{"dir1"}, result: []string{"dir1/file1", "dir1/subdir1/file1", "dir1/subdir1/file2"}},
|
||||
{dirs: []string{"dir2/*"}, result: []string{"dir2/subdir1/file1", "dir2/subdir1/file2"}},
|
||||
{dirs: []string{"dir2/subdir1"}, result: []string{"dir2/subdir1/file1", "dir2/subdir1/file2"}},
|
||||
{dirs: []string{"dir?"}, result: []string{"dir1/file1", "dir1/subdir1/file1", "dir1/subdir1/file2", "dir2/subdir1/file1", "dir2/subdir1/file2"}},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ func (c *comm) DownloadDir(src string, dst string, excl []string) error {
|
|||
|
||||
switch fi[0] {
|
||||
case '\x01', '\x02':
|
||||
return fmt.Errorf("%s", fi[1:len(fi)])
|
||||
return fmt.Errorf("%s", fi[1:])
|
||||
case 'C', 'D':
|
||||
break
|
||||
case 'E':
|
||||
|
@ -593,7 +593,7 @@ func (c *comm) scpDownloadSession(path string, output io.Writer) error {
|
|||
|
||||
switch fi[0] {
|
||||
case '\x01', '\x02':
|
||||
return fmt.Errorf("%s", fi[1:len(fi)])
|
||||
return fmt.Errorf("%s", fi[1:])
|
||||
case 'C':
|
||||
case 'D':
|
||||
return fmt.Errorf("remote file is directory")
|
||||
|
|
|
@ -18,7 +18,7 @@ func PasswordKeyboardInteractive(password string) ssh.KeyboardInteractiveChallen
|
|||
|
||||
// Just send the password back for all questions
|
||||
answers := make([]string, len(questions))
|
||||
for i, _ := range answers {
|
||||
for i := range answers {
|
||||
answers[i] = string(password)
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ func TestFixerCreateTime_Fix(t *testing.T) {
|
|||
|
||||
expected := map[string]interface{}{
|
||||
"builders": []map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
{
|
||||
"type": "foo",
|
||||
"ami_name": "{{timestamp}} foo",
|
||||
},
|
||||
|
|
|
@ -27,7 +27,7 @@ func TestFixerISOMD5_Fix(t *testing.T) {
|
|||
|
||||
expected := map[string]interface{}{
|
||||
"builders": []map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
{
|
||||
"type": "foo",
|
||||
"iso_checksum": "bar",
|
||||
"iso_checksum_type": "md5",
|
||||
|
|
|
@ -12,14 +12,14 @@ func testBuild() *coreBuild {
|
|||
builderConfig: 42,
|
||||
builderType: "foo",
|
||||
hooks: map[string][]Hook{
|
||||
"foo": []Hook{&MockHook{}},
|
||||
"foo": {&MockHook{}},
|
||||
},
|
||||
provisioners: []coreBuildProvisioner{
|
||||
coreBuildProvisioner{&MockProvisioner{}, []interface{}{42}},
|
||||
{&MockProvisioner{}, []interface{}{42}},
|
||||
},
|
||||
postProcessors: [][]coreBuildPostProcessor{
|
||||
[]coreBuildPostProcessor{
|
||||
coreBuildPostProcessor{&MockPostProcessor{ArtifactId: "pp"}, "testPP", make(map[string]interface{}), true},
|
||||
{
|
||||
{&MockPostProcessor{ArtifactId: "pp"}, "testPP", make(map[string]interface{}), true},
|
||||
},
|
||||
},
|
||||
variables: make(map[string]string),
|
||||
|
@ -246,8 +246,8 @@ func TestBuild_Run_Artifacts(t *testing.T) {
|
|||
// inputs, only that post-processors results are returned.
|
||||
build = testBuild()
|
||||
build.postProcessors = [][]coreBuildPostProcessor{
|
||||
[]coreBuildPostProcessor{
|
||||
coreBuildPostProcessor{&MockPostProcessor{ArtifactId: "pp"}, "pp", make(map[string]interface{}), false},
|
||||
{
|
||||
{&MockPostProcessor{ArtifactId: "pp"}, "pp", make(map[string]interface{}), false},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -271,11 +271,11 @@ func TestBuild_Run_Artifacts(t *testing.T) {
|
|||
// keeps the original, the original is kept.
|
||||
build = testBuild()
|
||||
build.postProcessors = [][]coreBuildPostProcessor{
|
||||
[]coreBuildPostProcessor{
|
||||
coreBuildPostProcessor{&MockPostProcessor{ArtifactId: "pp1"}, "pp", make(map[string]interface{}), false},
|
||||
{
|
||||
{&MockPostProcessor{ArtifactId: "pp1"}, "pp", make(map[string]interface{}), false},
|
||||
},
|
||||
[]coreBuildPostProcessor{
|
||||
coreBuildPostProcessor{&MockPostProcessor{ArtifactId: "pp2"}, "pp", make(map[string]interface{}), true},
|
||||
{
|
||||
{&MockPostProcessor{ArtifactId: "pp2"}, "pp", make(map[string]interface{}), true},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -299,13 +299,13 @@ func TestBuild_Run_Artifacts(t *testing.T) {
|
|||
// want to be.
|
||||
build = testBuild()
|
||||
build.postProcessors = [][]coreBuildPostProcessor{
|
||||
[]coreBuildPostProcessor{
|
||||
coreBuildPostProcessor{&MockPostProcessor{ArtifactId: "pp1a"}, "pp", make(map[string]interface{}), false},
|
||||
coreBuildPostProcessor{&MockPostProcessor{ArtifactId: "pp1b"}, "pp", make(map[string]interface{}), true},
|
||||
{
|
||||
{&MockPostProcessor{ArtifactId: "pp1a"}, "pp", make(map[string]interface{}), false},
|
||||
{&MockPostProcessor{ArtifactId: "pp1b"}, "pp", make(map[string]interface{}), true},
|
||||
},
|
||||
[]coreBuildPostProcessor{
|
||||
coreBuildPostProcessor{&MockPostProcessor{ArtifactId: "pp2a"}, "pp", make(map[string]interface{}), false},
|
||||
coreBuildPostProcessor{&MockPostProcessor{ArtifactId: "pp2b"}, "pp", make(map[string]interface{}), false},
|
||||
{
|
||||
{&MockPostProcessor{ArtifactId: "pp2a"}, "pp", make(map[string]interface{}), false},
|
||||
{&MockPostProcessor{ArtifactId: "pp2b"}, "pp", make(map[string]interface{}), false},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -329,8 +329,8 @@ func TestBuild_Run_Artifacts(t *testing.T) {
|
|||
// keeps inputs, that the artifacts are kept.
|
||||
build = testBuild()
|
||||
build.postProcessors = [][]coreBuildPostProcessor{
|
||||
[]coreBuildPostProcessor{
|
||||
coreBuildPostProcessor{
|
||||
{
|
||||
{
|
||||
&MockPostProcessor{ArtifactId: "pp", Keep: true}, "pp", make(map[string]interface{}), false,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -87,7 +87,7 @@ func NewCore(c *CoreConfig) (*Core, error) {
|
|||
// BuildNames returns the builds that are available in this configured core.
|
||||
func (c *Core) BuildNames() []string {
|
||||
r := make([]string, 0, len(c.builds))
|
||||
for n, _ := range c.builds {
|
||||
for n := range c.builds {
|
||||
r = append(r, n)
|
||||
}
|
||||
sort.Strings(r)
|
||||
|
|
|
@ -74,7 +74,7 @@ func TestDispatchHook_cancel(t *testing.T) {
|
|||
|
||||
dh := &DispatchHook{
|
||||
Mapping: map[string][]Hook{
|
||||
"foo": []Hook{hook},
|
||||
"foo": {hook},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -291,7 +291,7 @@ func (c *Client) Start() (addr net.Addr, err error) {
|
|||
// so they dont' block since it is an io.Pipe
|
||||
defer func() {
|
||||
go func() {
|
||||
for _ = range linesCh {
|
||||
for range linesCh {
|
||||
}
|
||||
}()
|
||||
}()
|
||||
|
|
|
@ -28,13 +28,13 @@ type guestOSTypeConfig struct {
|
|||
}
|
||||
|
||||
var guestOSTypeConfigs = map[string]guestOSTypeConfig{
|
||||
provisioner.UnixOSType: guestOSTypeConfig{
|
||||
provisioner.UnixOSType: {
|
||||
executeCommand: "{{if .Sudo}}sudo {{end}}chef-client --no-color -c {{.ConfigPath}} -j {{.JsonPath}}",
|
||||
installCommand: "curl -L https://www.chef.io/chef/install.sh | {{if .Sudo}}sudo {{end}}bash",
|
||||
knifeCommand: "{{if .Sudo}}sudo {{end}}knife {{.Args}} {{.Flags}}",
|
||||
stagingDir: "/tmp/packer-chef-client",
|
||||
},
|
||||
provisioner.WindowsOSType: guestOSTypeConfig{
|
||||
provisioner.WindowsOSType: {
|
||||
executeCommand: "c:/opscode/chef/bin/chef-client.bat --no-color -c {{.ConfigPath}} -j {{.JsonPath}}",
|
||||
installCommand: "powershell.exe -Command \"(New-Object System.Net.WebClient).DownloadFile('http://chef.io/chef/install.msi', 'C:\\Windows\\Temp\\chef.msi');Start-Process 'msiexec' -ArgumentList '/qb /i C:\\Windows\\Temp\\chef.msi' -NoNewWindow -Wait\"",
|
||||
knifeCommand: "c:/opscode/chef/bin/knife.bat {{.Args}} {{.Flags}}",
|
||||
|
|
|
@ -26,12 +26,12 @@ type guestOSTypeConfig struct {
|
|||
}
|
||||
|
||||
var guestOSTypeConfigs = map[string]guestOSTypeConfig{
|
||||
provisioner.UnixOSType: guestOSTypeConfig{
|
||||
provisioner.UnixOSType: {
|
||||
executeCommand: "{{if .Sudo}}sudo {{end}}chef-solo --no-color -c {{.ConfigPath}} -j {{.JsonPath}}",
|
||||
installCommand: "curl -L https://omnitruck.chef.io/install.sh | {{if .Sudo}}sudo {{end}}bash",
|
||||
stagingDir: "/tmp/packer-chef-solo",
|
||||
},
|
||||
provisioner.WindowsOSType: guestOSTypeConfig{
|
||||
provisioner.WindowsOSType: {
|
||||
executeCommand: "c:/opscode/chef/bin/chef-solo.bat --no-color -c {{.ConfigPath}} -j {{.JsonPath}}",
|
||||
installCommand: "powershell.exe -Command \". { iwr -useb https://omnitruck.chef.io/install.ps1 } | iex; install\"",
|
||||
stagingDir: "C:/Windows/Temp/packer-chef-solo",
|
||||
|
|
|
@ -16,12 +16,12 @@ type guestOSTypeCommand struct {
|
|||
}
|
||||
|
||||
var guestOSTypeCommands = map[string]guestOSTypeCommand{
|
||||
UnixOSType: guestOSTypeCommand{
|
||||
UnixOSType: {
|
||||
chmod: "chmod %s '%s'",
|
||||
mkdir: "mkdir -p '%s'",
|
||||
removeDir: "rm -rf '%s'",
|
||||
},
|
||||
WindowsOSType: guestOSTypeCommand{
|
||||
WindowsOSType: {
|
||||
chmod: "echo 'skipping chmod %s %s'", // no-op
|
||||
mkdir: "powershell.exe -Command \"New-Item -ItemType directory -Force -ErrorAction SilentlyContinue -Path %s\"",
|
||||
removeDir: "powershell.exe -Command \"rm %s -recurse -force\"",
|
||||
|
|
|
@ -19,7 +19,7 @@ func TestFunctionsCalled(t *testing.T) {
|
|||
{
|
||||
"foo {{user `bar`}}",
|
||||
map[string]struct{}{
|
||||
"user": struct{}{},
|
||||
"user": {},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ func TestParse(t *testing.T) {
|
|||
"parse-basic.json",
|
||||
&Template{
|
||||
Builders: map[string]*Builder{
|
||||
"something": &Builder{
|
||||
"something": {
|
||||
Name: "something",
|
||||
Type: "something",
|
||||
},
|
||||
|
@ -47,7 +47,7 @@ func TestParse(t *testing.T) {
|
|||
"parse-provisioner-basic.json",
|
||||
&Template{
|
||||
Provisioners: []*Provisioner{
|
||||
&Provisioner{
|
||||
{
|
||||
Type: "something",
|
||||
},
|
||||
},
|
||||
|
@ -59,7 +59,7 @@ func TestParse(t *testing.T) {
|
|||
"parse-provisioner-pause-before.json",
|
||||
&Template{
|
||||
Provisioners: []*Provisioner{
|
||||
&Provisioner{
|
||||
{
|
||||
Type: "something",
|
||||
PauseBefore: 1 * time.Second,
|
||||
},
|
||||
|
@ -72,7 +72,7 @@ func TestParse(t *testing.T) {
|
|||
"parse-provisioner-only.json",
|
||||
&Template{
|
||||
Provisioners: []*Provisioner{
|
||||
&Provisioner{
|
||||
{
|
||||
Type: "something",
|
||||
OnlyExcept: OnlyExcept{
|
||||
Only: []string{"foo"},
|
||||
|
@ -87,7 +87,7 @@ func TestParse(t *testing.T) {
|
|||
"parse-provisioner-except.json",
|
||||
&Template{
|
||||
Provisioners: []*Provisioner{
|
||||
&Provisioner{
|
||||
{
|
||||
Type: "something",
|
||||
OnlyExcept: OnlyExcept{
|
||||
Except: []string{"foo"},
|
||||
|
@ -102,7 +102,7 @@ func TestParse(t *testing.T) {
|
|||
"parse-provisioner-override.json",
|
||||
&Template{
|
||||
Provisioners: []*Provisioner{
|
||||
&Provisioner{
|
||||
{
|
||||
Type: "something",
|
||||
Override: map[string]interface{}{
|
||||
"foo": map[string]interface{}{},
|
||||
|
@ -123,7 +123,7 @@ func TestParse(t *testing.T) {
|
|||
"parse-variable-default.json",
|
||||
&Template{
|
||||
Variables: map[string]*Variable{
|
||||
"foo": &Variable{
|
||||
"foo": {
|
||||
Default: "foo",
|
||||
},
|
||||
},
|
||||
|
@ -135,7 +135,7 @@ func TestParse(t *testing.T) {
|
|||
"parse-variable-required.json",
|
||||
&Template{
|
||||
Variables: map[string]*Variable{
|
||||
"foo": &Variable{
|
||||
"foo": {
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
|
@ -147,8 +147,8 @@ func TestParse(t *testing.T) {
|
|||
"parse-pp-basic.json",
|
||||
&Template{
|
||||
PostProcessors: [][]*PostProcessor{
|
||||
[]*PostProcessor{
|
||||
&PostProcessor{
|
||||
{
|
||||
{
|
||||
Type: "foo",
|
||||
Config: map[string]interface{}{
|
||||
"foo": "bar",
|
||||
|
@ -164,8 +164,8 @@ func TestParse(t *testing.T) {
|
|||
"parse-pp-keep.json",
|
||||
&Template{
|
||||
PostProcessors: [][]*PostProcessor{
|
||||
[]*PostProcessor{
|
||||
&PostProcessor{
|
||||
{
|
||||
{
|
||||
Type: "foo",
|
||||
KeepInputArtifact: true,
|
||||
},
|
||||
|
@ -179,8 +179,8 @@ func TestParse(t *testing.T) {
|
|||
"parse-pp-only.json",
|
||||
&Template{
|
||||
PostProcessors: [][]*PostProcessor{
|
||||
[]*PostProcessor{
|
||||
&PostProcessor{
|
||||
{
|
||||
{
|
||||
Type: "foo",
|
||||
OnlyExcept: OnlyExcept{
|
||||
Only: []string{"bar"},
|
||||
|
@ -196,8 +196,8 @@ func TestParse(t *testing.T) {
|
|||
"parse-pp-except.json",
|
||||
&Template{
|
||||
PostProcessors: [][]*PostProcessor{
|
||||
[]*PostProcessor{
|
||||
&PostProcessor{
|
||||
{
|
||||
{
|
||||
Type: "foo",
|
||||
OnlyExcept: OnlyExcept{
|
||||
Except: []string{"bar"},
|
||||
|
@ -213,8 +213,8 @@ func TestParse(t *testing.T) {
|
|||
"parse-pp-string.json",
|
||||
&Template{
|
||||
PostProcessors: [][]*PostProcessor{
|
||||
[]*PostProcessor{
|
||||
&PostProcessor{
|
||||
{
|
||||
{
|
||||
Type: "foo",
|
||||
},
|
||||
},
|
||||
|
@ -227,8 +227,8 @@ func TestParse(t *testing.T) {
|
|||
"parse-pp-map.json",
|
||||
&Template{
|
||||
PostProcessors: [][]*PostProcessor{
|
||||
[]*PostProcessor{
|
||||
&PostProcessor{
|
||||
{
|
||||
{
|
||||
Type: "foo",
|
||||
},
|
||||
},
|
||||
|
@ -241,13 +241,13 @@ func TestParse(t *testing.T) {
|
|||
"parse-pp-slice.json",
|
||||
&Template{
|
||||
PostProcessors: [][]*PostProcessor{
|
||||
[]*PostProcessor{
|
||||
&PostProcessor{
|
||||
{
|
||||
{
|
||||
Type: "foo",
|
||||
},
|
||||
},
|
||||
[]*PostProcessor{
|
||||
&PostProcessor{
|
||||
{
|
||||
{
|
||||
Type: "bar",
|
||||
},
|
||||
},
|
||||
|
@ -260,11 +260,11 @@ func TestParse(t *testing.T) {
|
|||
"parse-pp-multi.json",
|
||||
&Template{
|
||||
PostProcessors: [][]*PostProcessor{
|
||||
[]*PostProcessor{
|
||||
&PostProcessor{
|
||||
{
|
||||
{
|
||||
Type: "foo",
|
||||
},
|
||||
&PostProcessor{
|
||||
{
|
||||
Type: "bar",
|
||||
},
|
||||
},
|
||||
|
@ -309,7 +309,7 @@ func TestParse(t *testing.T) {
|
|||
"parse-comment.json",
|
||||
&Template{
|
||||
Builders: map[string]*Builder{
|
||||
"something": &Builder{
|
||||
"something": {
|
||||
Name: "something",
|
||||
Type: "something",
|
||||
},
|
||||
|
|
|
@ -107,7 +107,7 @@ func (t *Template) Validate() error {
|
|||
}
|
||||
|
||||
// Validate overrides
|
||||
for name, _ := range p.Override {
|
||||
for name := range p.Override {
|
||||
if _, ok := t.Builders[name]; !ok {
|
||||
err = multierror.Append(err, fmt.Errorf(
|
||||
"provisioner %d: override '%s' doesn't exist",
|
||||
|
|
Loading…
Reference in New Issue