Fix golint errors
Signed-off-by: Nathan LeClaire <nathan.leclaire@gmail.com>
This commit is contained in:
@@ -23,8 +23,8 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrHostLoad = errors.New("All specified hosts had errors loading their configuration.")
|
||||
ErrNoDefault = fmt.Errorf("Error: No machine name(s) specified and no %q machine exists.", defaultMachineName)
|
||||
ErrHostLoad = errors.New("All specified hosts had errors loading their configuration")
|
||||
ErrNoDefault = fmt.Errorf("Error: No machine name(s) specified and no %q machine exists", defaultMachineName)
|
||||
ErrNoMachineSpecified = errors.New("Error: Expected to get one or more machine names as arguments")
|
||||
ErrExpectedOneMachine = errors.New("Error: Expected one machine name as an argument")
|
||||
ErrTooManyArguments = errors.New("Error: Too many arguments given")
|
||||
|
||||
@@ -41,7 +41,7 @@ func cmdInspect(c CommandLine, api libmachine.API) error {
|
||||
var tmpl *template.Template
|
||||
var err error
|
||||
if tmpl, err = template.New("").Funcs(funcMap).Parse(tmplString); err != nil {
|
||||
return fmt.Errorf("Template parsing error: %v\n", err)
|
||||
return fmt.Errorf("template parsing error: %v", err)
|
||||
}
|
||||
|
||||
jsonHost, err := json.Marshal(host)
|
||||
|
||||
@@ -181,7 +181,7 @@ func parseFilters(filters []string) (FilterOptions, error) {
|
||||
for _, f := range filters {
|
||||
kv := strings.SplitN(f, "=", 2)
|
||||
if len(kv) != 2 {
|
||||
return options, errors.New("Unsupported filter syntax.")
|
||||
return options, errors.New("Unsupported filter syntax")
|
||||
}
|
||||
key, value := strings.ToLower(kv[0]), kv[1]
|
||||
|
||||
@@ -468,7 +468,7 @@ func newHostListItemInError(name string, err error) HostListItem {
|
||||
Name: name,
|
||||
DriverName: "not found",
|
||||
State: state.Error,
|
||||
Error: strings.Replace(err.Error(), "\n", " ", -1),
|
||||
Error: strings.Replace(err.Error(), "\n", "", -1),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -527,9 +527,9 @@ func TestGetSomeHostInError(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOnErrorWithMultilineComment(t *testing.T) {
|
||||
err := errors.New("MissingParameter: The request must contain the parameter InstanceId\n status code: 400, request id:")
|
||||
err := errors.New("missing parameter: the request must contain the parameter InstanceId\n status code: 400")
|
||||
|
||||
itemInError := newHostListItemInError("foo", err)
|
||||
|
||||
assert.Equal(t, itemInError.Error, "MissingParameter: The request must contain the parameter InstanceId status code: 400, request id:")
|
||||
assert.Equal(t, itemInError.Error, "missing parameter: the request must contain the parameter InstanceId status code: 400")
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ func cmdScp(c CommandLine, api libmachine.API) error {
|
||||
func getScpCmd(src, dest string, recursive bool, hostInfoLoader HostInfoLoader) (*exec.Cmd, error) {
|
||||
cmdPath, err := exec.LookPath("scp")
|
||||
if err != nil {
|
||||
return nil, errors.New("Error: You must have a copy of the scp binary locally to use the scp feature.")
|
||||
return nil, errors.New("You must have a copy of the scp binary locally to use the scp feature")
|
||||
}
|
||||
|
||||
srcHost, srcPath, srcOpts, err := getInfoForScpArg(src, hostInfoLoader)
|
||||
|
||||
@@ -562,9 +562,9 @@ func (d *Driver) Kill() error {
|
||||
func (d *Driver) checkLegacyDriver(short bool) error {
|
||||
if d.ResourceGroup == "" {
|
||||
if short {
|
||||
return errors.New("New azure driver cannot manage old VMs, downgrade to v0.6.0")
|
||||
return errors.New("new azure driver cannot manage old VMs, downgrade to v0.6.0")
|
||||
}
|
||||
return errors.New("New azure driver uses the new Azure Resource Manager APIs and therefore cannot manage this existing machine created with old azure driver. Please downgrade to docker-machine 0.6.0 to continue using these machines or to remove them.")
|
||||
return errors.New("new azure driver uses the new Azure Resource Manager APIs and therefore cannot manage this existing machine created with old azure driver. Please downgrade to docker-machine 0.6.0 to continue using these machines or to remove them")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ func (a AzureClient) RegisterResourceProviders(namespaces ...string) error {
|
||||
return err
|
||||
}
|
||||
if l.Value == nil {
|
||||
return errors.New("Resource Providers list is returned as nil.")
|
||||
return errors.New("resource providers list is returned as nil")
|
||||
}
|
||||
|
||||
m := make(map[string]bool)
|
||||
@@ -72,7 +72,7 @@ func (a AzureClient) RegisterResourceProviders(namespaces ...string) error {
|
||||
for _, ns := range namespaces {
|
||||
registered, ok := m[strings.ToLower(ns)]
|
||||
if !ok {
|
||||
return fmt.Errorf("Unknown resource provider %q", ns)
|
||||
return fmt.Errorf("unknown resource provider %q", ns)
|
||||
}
|
||||
if registered {
|
||||
log.Debugf("Already registered for %q", ns)
|
||||
|
||||
@@ -37,7 +37,7 @@ type imageName struct{ publisher, offer, sku, version string }
|
||||
func parseImageName(image string) (imageName, error) {
|
||||
l := strings.Split(image, ":")
|
||||
if len(l) != 4 {
|
||||
return imageName{}, fmt.Errorf("Image name %q not a valid format.", image)
|
||||
return imageName{}, fmt.Errorf("image name %q not a valid format", image)
|
||||
}
|
||||
return imageName{l[0], l[1], l[2], l[3]}, nil
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package exoscale
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
@@ -166,7 +167,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
||||
d.URL = "https://api.exoscale.ch/compute"
|
||||
}
|
||||
if d.APIKey == "" || d.APISecretKey == "" {
|
||||
return fmt.Errorf("Please specify an API key (--exoscale-api-key) and an API secret key (--exoscale-api-secret-key).")
|
||||
return errors.New("missing an API key (--exoscale-api-key) or API secret key (--exoscale-api-secret-key)")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package google
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
@@ -173,7 +174,7 @@ func (d *Driver) DriverName() string {
|
||||
func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
||||
d.Project = flags.String("google-project")
|
||||
if d.Project == "" {
|
||||
return fmt.Errorf("Please specify the Google Cloud Project name using the option --google-project.")
|
||||
return errors.New("no Google Cloud Project name specified (--google-project)")
|
||||
}
|
||||
|
||||
d.Zone = flags.String("google-zone")
|
||||
@@ -220,11 +221,11 @@ func (d *Driver) PreCreateCheck() error {
|
||||
instance, _ := c.instance()
|
||||
if d.UseExisting {
|
||||
if instance == nil {
|
||||
return fmt.Errorf("Unable to find instance %q in zone %q.", d.MachineName, d.Zone)
|
||||
return fmt.Errorf("unable to find instance %q in zone %q", d.MachineName, d.Zone)
|
||||
}
|
||||
} else {
|
||||
if instance != nil {
|
||||
return fmt.Errorf("Instance %q already exists in zone %q.", d.MachineName, d.Zone)
|
||||
return fmt.Errorf("instance %q already exists in zone %q", d.MachineName, d.Zone)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
||||
}
|
||||
|
||||
if d.EndpointType != "publicURL" && d.EndpointType != "adminURL" && d.EndpointType != "internalURL" {
|
||||
return fmt.Errorf(`Invalid endpoint type "%s". Endpoint type must be publicURL, adminURL or internalURL.`, d.EndpointType)
|
||||
return fmt.Errorf("invalid endpoint type %q (must be publicURL, adminURL or internalURL)", d.EndpointType)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -140,13 +140,13 @@ func listHostOnlyAdapters(vbox VBoxManager) (map[string]*hostOnlyNetwork, error)
|
||||
n.NetworkName = val
|
||||
|
||||
if _, present := byName[n.NetworkName]; present {
|
||||
return fmt.Errorf("VirtualBox is configured with multiple host-only adapters with the same name %q. Please remove one.", n.NetworkName)
|
||||
return fmt.Errorf("VirtualBox is configured with multiple host-only adapters with the same name %q. Please remove one", n.NetworkName)
|
||||
}
|
||||
byName[n.NetworkName] = n
|
||||
|
||||
if len(n.IPv4.IP) != 0 {
|
||||
if _, present := byIP[n.IPv4.IP.String()]; present {
|
||||
return fmt.Errorf("VirtualBox is configured with multiple host-only adapters with the same IP %q. Please remove one.", n.IPv4.IP)
|
||||
return fmt.Errorf("VirtualBox is configured with multiple host-only adapters with the same IP %q. Please remove one", n.IPv4.IP)
|
||||
}
|
||||
byIP[n.IPv4.IP.String()] = n
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ VBoxNetworkName: HostInterfaceNetworking-vboxnet1`,
|
||||
}
|
||||
nets, err := listHostOnlyAdapters(vbox)
|
||||
assert.Nil(t, nets)
|
||||
assert.EqualError(t, err, `VirtualBox is configured with multiple host-only adapters with the same IP "192.168.99.1". Please remove one.`)
|
||||
assert.EqualError(t, err, `VirtualBox is configured with multiple host-only adapters with the same IP "192.168.99.1". Please remove one`)
|
||||
}
|
||||
|
||||
func TestFailIfTwoNetworksHaveSameName(t *testing.T) {
|
||||
@@ -288,7 +288,7 @@ VBoxNetworkName: HostInterfaceNetworking-vboxnet0`,
|
||||
}
|
||||
nets, err := listHostOnlyAdapters(vbox)
|
||||
assert.Nil(t, nets)
|
||||
assert.EqualError(t, err, `VirtualBox is configured with multiple host-only adapters with the same name "HostInterfaceNetworking-vboxnet0". Please remove one.`)
|
||||
assert.EqualError(t, err, `VirtualBox is configured with multiple host-only adapters with the same name "HostInterfaceNetworking-vboxnet0". Please remove one`)
|
||||
}
|
||||
|
||||
func TestGetDHCPServers(t *testing.T) {
|
||||
|
||||
@@ -11,6 +11,6 @@ func TestInspect(t *testing.T) {
|
||||
defer test.TearDown()
|
||||
|
||||
test.Run("inspect: show error in case of no args", func() {
|
||||
test.Machine("inspect").Should().Fail(`Error: No machine name(s) specified and no "default" machine exists.`)
|
||||
test.Machine("inspect").Should().Fail(`Error: No machine name(s) specified and no "default" machine exists`)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ func TestStatus(t *testing.T) {
|
||||
defer test.TearDown()
|
||||
|
||||
test.Run("status: show error in case of no args", func() {
|
||||
test.Machine("status").Should().Fail(`Error: No machine name(s) specified and no "default" machine exists.`)
|
||||
test.Machine("status").Should().Fail(`Error: No machine name(s) specified and no "default" machine exists`)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ func TestUrl(t *testing.T) {
|
||||
defer test.TearDown()
|
||||
|
||||
test.Run("url: show error in case of no args", func() {
|
||||
test.Machine("url").Should().Fail(`Error: No machine name(s) specified and no "default" machine exists.`)
|
||||
test.Machine("url").Should().Fail(`Error: No machine name(s) specified and no "default" machine exists`)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ func BootstrapCertificates(authOptions *auth.Options) error {
|
||||
|
||||
// check if the key path exists; if so, error
|
||||
if _, err := os.Stat(caPrivateKeyPath); err == nil {
|
||||
return errors.New("The CA key already exists. Please remove it or specify a different key/cert.")
|
||||
return errors.New("certificate authority key already exists")
|
||||
}
|
||||
|
||||
if err := GenerateCACertificate(caCertPath, caPrivateKeyPath, caOrg, bits); err != nil {
|
||||
@@ -54,7 +54,7 @@ func BootstrapCertificates(authOptions *auth.Options) error {
|
||||
if _, err := os.Stat(certDir); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
if err := os.Mkdir(certDir, 0700); err != nil {
|
||||
return fmt.Errorf("Creating machine client cert dir failed: %s", err)
|
||||
return fmt.Errorf("failure creating machine client cert dir: %s", err)
|
||||
}
|
||||
} else {
|
||||
return err
|
||||
@@ -63,7 +63,7 @@ func BootstrapCertificates(authOptions *auth.Options) error {
|
||||
|
||||
// check if the key path exists; if so, error
|
||||
if _, err := os.Stat(clientKeyPath); err == nil {
|
||||
return errors.New("The client key already exists. Please remove it or specify a different key/cert.")
|
||||
return errors.New("client key already exists")
|
||||
}
|
||||
|
||||
// Used to generate the client certificate.
|
||||
@@ -79,7 +79,7 @@ func BootstrapCertificates(authOptions *auth.Options) error {
|
||||
}
|
||||
|
||||
if err := GenerateCert(certOptions); err != nil {
|
||||
return fmt.Errorf("Generating client certificate failed: %s", err)
|
||||
return fmt.Errorf("failure generating client certificate: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ func (r *BugsnagCrashReporter) Send(err CrashError) error {
|
||||
}
|
||||
|
||||
if r.apiKey == "" {
|
||||
return errors.New("Not sending report since no api key has been set.")
|
||||
return errors.New("no api key has been set")
|
||||
}
|
||||
|
||||
bugsnag.Configure(bugsnag.Configuration{
|
||||
|
||||
@@ -44,11 +44,10 @@ func RunSSHCommandFromDriver(d Driver, command string) (string, error) {
|
||||
output, err := client.Output(command)
|
||||
log.Debugf("SSH cmd err, output: %v: %s", err, output)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf(`Something went wrong running an SSH command!
|
||||
return "", fmt.Errorf(`ssh command error:
|
||||
command : %s
|
||||
err : %v
|
||||
output : %s
|
||||
`, command, err, output)
|
||||
output : %s`, command, err, output)
|
||||
}
|
||||
|
||||
return output, nil
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
|
||||
var (
|
||||
validHostNamePattern = regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9\-\.]*$`)
|
||||
errMachineMustBeRunningForUpgrade = errors.New("Error: machine must be running to upgrade.")
|
||||
errMachineMustBeRunningForUpgrade = errors.New("machine must be running to upgrade")
|
||||
stdSSHClientCreator SSHClientCreator = &StandardSSHClientCreator{}
|
||||
)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
errConfigFromFuture = errors.New("Config version is from the future, please upgrade your Docker Machine client.")
|
||||
errConfigFromFuture = errors.New("config version is from the future -- you should upgrade your Docker Machine client")
|
||||
)
|
||||
|
||||
type RawDataDriver struct {
|
||||
|
||||
@@ -33,8 +33,7 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
errGitHubAPIResponse = errors.New(`Error getting a version tag from the Github API response.
|
||||
You may be getting rate limited by Github.`)
|
||||
errGitHubAPIResponse = errors.New(`failure getting a version tag from the Github API response (are you getting rate limited by Github?)`)
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -35,11 +35,10 @@ func (sshCmder RedHatSSHCommander) SSHCommand(args string) (string, error) {
|
||||
|
||||
log.Debugf("SSH cmd err, output: %v: %s", err, output)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf(`Something went wrong running an SSH command!
|
||||
return "", fmt.Errorf(`something went wrong running an SSH command
|
||||
command : %s
|
||||
err : %v
|
||||
output : %s
|
||||
`, args, err, output)
|
||||
output : %s`, args, err, output)
|
||||
}
|
||||
|
||||
return output, nil
|
||||
|
||||
@@ -28,7 +28,7 @@ func installDockerGeneric(p Provisioner, baseURL string) error {
|
||||
// install docker - until cloudinit we use ubuntu everywhere so we
|
||||
// just install it using the docker repos
|
||||
if output, err := p.SSHCommand(fmt.Sprintf("if ! type docker; then curl -sSL %s | sh -; fi", baseURL)); err != nil {
|
||||
return fmt.Errorf("error installing docker: %s\n", output)
|
||||
return fmt.Errorf("error installing docker: %s", output)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user