golint: Fix lint offences

This commit is contained in:
Mikhail Zholobov 2016-12-12 00:37:41 +02:00
parent 00a90e622b
commit 73d87b07de
No known key found for this signature in database
GPG Key ID: 467E2D8B15AE6DB3
16 changed files with 45 additions and 34 deletions

View File

@ -9,7 +9,7 @@ import (
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
) )
// This is the common builder ID to all of these artifacts. // BuilderId is the common builder ID to all of these artifacts.
const BuilderId = "packer.parallels" const BuilderId = "packer.parallels"
// These are the extensions of files and directories that are unnecessary for the function // These are the extensions of files and directories that are unnecessary for the function

View File

@ -9,7 +9,7 @@ import (
"strings" "strings"
) )
// A driver is able to talk to Parallels and perform certain // Driver is the interface that talks to Parallels and performs certain
// operations with it. Some of the operations on here may seem overly // operations with it. Some of the operations on here may seem overly
// specific, but they were built specifically in mind to handle features // specific, but they were built specifically in mind to handle features
// of the Parallels builder for Packer, and to abstract differences in // of the Parallels builder for Packer, and to abstract differences in

View File

@ -24,13 +24,12 @@ func (d *Parallels11Driver) Verify() error {
if matches == nil { if matches == nil {
return fmt.Errorf( return fmt.Errorf(
"Could not determine your Parallels Desktop edition using: %s info --license", d.PrlsrvctlPath) "Could not determine your Parallels Desktop edition using: %s info --license", d.PrlsrvctlPath)
} else { }
switch matches[1] { switch matches[1] {
case "pro", "business": case "pro", "business":
break break
default: default:
return fmt.Errorf("Packer can be used only with Parallels Desktop 11 Pro or Business edition. You use: %s edition", matches[1]) return fmt.Errorf("Packer can be used only with Parallels Desktop 11 Pro or Business edition. You use: %s edition", matches[1])
}
} }
return nil return nil

View File

@ -1,6 +1,6 @@
package common package common
// Interface to help find the host IP that is available from within // HostIPFinder allows to find the host IP that is available from within
// the Parallels virtual machines. // the Parallels virtual machines.
type HostIPFinder interface { type HostIPFinder interface {
HostIP() (string, error) HostIP() (string, error)

View File

@ -50,5 +50,5 @@ func (f *IfconfigIPFinder) HostIP() (string, error) {
} }
} }
} }
return "", errors.New("IP not found in ifconfig output...") return "", errors.New("IP not found in ifconfig output")
} }

View File

@ -8,7 +8,7 @@ import (
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
) )
// This step attaches a floppy to the virtual machine. // StepAttachFloppy is a step that attaches a floppy to the virtual machine.
// //
// Uses: // Uses:
// driver Driver // driver Driver

View File

@ -8,8 +8,8 @@ import (
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
) )
// This step attaches the Parallels Tools as an inserted CD onto // StepAttachParallelsTools is a step that attaches Parallels Tools ISO image
// the virtual machine. // as an inserted CD onto the virtual machine.
// //
// Uses: // Uses:
// driver Driver // driver Driver

View File

@ -7,8 +7,8 @@ import (
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
) )
// This step removes all empty blocks from expanding Parallels virtual disks // StepCompactDisk is a step that removes all empty blocks from expanding
// and reduces the result disk size // Parallels virtual disks and reduces the result disk size
// //
// Uses: // Uses:
// driver Driver // driver Driver

View File

@ -7,7 +7,8 @@ import (
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
) )
// This step prepares parameters related to Parallels Tools. // StepPrepareParallelsTools is a step that prepares parameters related
// to Parallels Tools.
// //
// Uses: // Uses:
// driver Driver // driver Driver

View File

@ -13,8 +13,8 @@ type commandTemplate struct {
Name string Name string
} }
// This step executes additional prlctl commands as specified by the // StepPrlctl is a step that executes additional prlctl commands as specified
// template. // by the template.
// //
// Uses: // Uses:
// driver Driver // driver Driver

View File

@ -8,7 +8,7 @@ import (
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
) )
// This step starts the virtual machine. // StepRun is a step that starts the virtual machine.
// //
// Uses: // Uses:
// driver Driver // driver Driver

View File

@ -10,8 +10,8 @@ import (
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
) )
// This step shuts down the machine. It first attempts to do so gracefully, // StepShutdown is a step that shuts down the machine. It first attempts to do
// but ultimately forcefully shuts it down if that fails. // so gracefully, but ultimately forcefully shuts it down if that fails.
// //
// Uses: // Uses:
// communicator packer.Communicator // communicator packer.Communicator

View File

@ -19,8 +19,8 @@ type bootCommandTemplateData struct {
Name string Name string
} }
// This step "types" the boot command into the VM via the prltype script, built on the // StepTypeBootCommand is a step that "types" the boot command into the VM via
// Parallels Virtualization SDK - Python API. // the prltype script, built on the Parallels Virtualization SDK - Python API.
// //
// Uses: // Uses:
// driver Driver // driver Driver
@ -48,7 +48,7 @@ func (s *StepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction
pauseFn = state.Get("pauseFn").(multistep.DebugPauseFn) pauseFn = state.Get("pauseFn").(multistep.DebugPauseFn)
} }
hostIp := "0.0.0.0" hostIP := "0.0.0.0"
if len(s.HostInterfaces) > 0 { if len(s.HostInterfaces) > 0 {
// Determine the host IP // Determine the host IP
@ -61,13 +61,13 @@ func (s *StepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction
ui.Error(err.Error()) ui.Error(err.Error())
return multistep.ActionHalt return multistep.ActionHalt
} }
hostIp = ip hostIP = ip
} }
ui.Say(fmt.Sprintf("Host IP for the Parallels machine: %s", hostIp)) ui.Say(fmt.Sprintf("Host IP for the Parallels machine: %s", hostIP))
s.Ctx.Data = &bootCommandTemplateData{ s.Ctx.Data = &bootCommandTemplateData{
hostIp, hostIP,
httpPort, httpPort,
s.VMName, s.VMName,
} }
@ -206,12 +206,12 @@ func scancodes(message string) []string {
scancodeMap := make(map[rune]uint) scancodeMap := make(map[rune]uint)
for chars, start := range scancodeIndex { for chars, start := range scancodeIndex {
var i uint = 0 var i uint
for len(chars) > 0 { for len(chars) > 0 {
r, size := utf8.DecodeRuneInString(chars) r, size := utf8.DecodeRuneInString(chars)
chars = chars[size:] chars = chars[size:]
scancodeMap[r] = start + i scancodeMap[r] = start + i
i += 1 i++
} }
} }

View File

@ -22,7 +22,13 @@ type toolsPathTemplate struct {
Flavor string Flavor string
} }
// This step uploads the guest additions ISO to the VM. // StepUploadParallelsTools is a step that uploads the Parallels Tools ISO
// to the VM.
//
// Uses:
// communicator packer.Communicator
// parallels_tools_path string
// ui packer.Ui
type StepUploadParallelsTools struct { type StepUploadParallelsTools struct {
ParallelsToolsFlavor string ParallelsToolsFlavor string
ParallelsToolsGuestPath string ParallelsToolsGuestPath string

View File

@ -9,8 +9,13 @@ import (
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
) )
// This step uploads a file containing the Parallels version, which // StepUploadVersion is a step that uploads a file containing the version of
// can be useful for various provisioning reasons. // Parallels Desktop, which can be useful for various provisioning reasons.
//
// Uses:
// communicator packer.Communicator
// driver Driver
// ui packer.Ui
type StepUploadVersion struct { type StepUploadVersion struct {
Path string Path string
} }

View File

@ -53,7 +53,7 @@ func (c *ToolsConfig) Prepare(ctx *interpolate.Context) []error {
if c.ParallelsToolsFlavor == "" { if c.ParallelsToolsFlavor == "" {
if c.ParallelsToolsMode != ParallelsToolsModeDisable { if c.ParallelsToolsMode != ParallelsToolsModeDisable {
errs = append(errs, errors.New("parallels_tools_flavor must be specified.")) errs = append(errs, errors.New("parallels_tools_flavor must be specified"))
} }
} }