Clean up error logs.

Use %v for errors, tidy some messages, make error messages start lowe-case
(as per go guidelines).  Just accumulated nits.
This commit is contained in:
Tim Hockin
2014-11-20 18:00:36 +08:00
parent c688bd402f
commit ea960711ff
53 changed files with 163 additions and 163 deletions

View File

@@ -61,7 +61,7 @@ func getAuth() (auth aws.Auth, err error) {
// readAWSCloudConfig reads an instance of AWSCloudConfig from config reader.
func readAWSCloudConfig(config io.Reader) (*AWSCloudConfig, error) {
if config == nil {
return nil, fmt.Errorf("No AWS cloud provider config file given")
return nil, fmt.Errorf("no AWS cloud provider config file given")
}
var cfg AWSCloudConfig
@@ -71,7 +71,7 @@ func readAWSCloudConfig(config io.Reader) (*AWSCloudConfig, error) {
}
if cfg.Global.Region == "" {
return nil, fmt.Errorf("No region specified in configuration file")
return nil, fmt.Errorf("no region specified in configuration file")
}
return &cfg, nil
@@ -81,7 +81,7 @@ func readAWSCloudConfig(config io.Reader) (*AWSCloudConfig, error) {
func newAWSCloud(config io.Reader, authFunc AuthFunc) (*AWSCloud, error) {
cfg, err := readAWSCloudConfig(config)
if err != nil {
return nil, fmt.Errorf("Unable to read AWS cloud provider config file: %s", err)
return nil, fmt.Errorf("unable to read AWS cloud provider config file: %v", err)
}
auth, err := authFunc()
@@ -91,7 +91,7 @@ func newAWSCloud(config io.Reader, authFunc AuthFunc) (*AWSCloud, error) {
region, ok := aws.Regions[cfg.Global.Region]
if !ok {
return nil, fmt.Errorf("Not a valid AWS region: %s", cfg.Global.Region)
return nil, fmt.Errorf("not a valid AWS region: %s", cfg.Global.Region)
}
ec2 := ec2.New(auth, region)
@@ -130,22 +130,22 @@ func (aws *AWSCloud) IPAddress(name string) (net.IP, error) {
return nil, err
}
if len(resp.Reservations) == 0 {
return nil, fmt.Errorf("No reservations found for host: %s", name)
return nil, fmt.Errorf("no reservations found for host: %s", name)
}
if len(resp.Reservations) > 1 {
return nil, fmt.Errorf("Multiple reservations found for host: %s", name)
return nil, fmt.Errorf("multiple reservations found for host: %s", name)
}
if len(resp.Reservations[0].Instances) == 0 {
return nil, fmt.Errorf("No instances found for host: %s", name)
return nil, fmt.Errorf("no instances found for host: %s", name)
}
if len(resp.Reservations[0].Instances) > 1 {
return nil, fmt.Errorf("Multiple instances found for host: %s", name)
return nil, fmt.Errorf("multiple instances found for host: %s", name)
}
ipAddress := resp.Reservations[0].Instances[0].PrivateIpAddress
ip := net.ParseIP(ipAddress)
if ip == nil {
return nil, fmt.Errorf("Invalid network IP: %s", ipAddress)
return nil, fmt.Errorf("invalid network IP: %s", ipAddress)
}
return ip, nil
}
@@ -157,7 +157,7 @@ func (aws *AWSCloud) getInstancesByRegex(regex string) ([]string, error) {
return []string{}, err
}
if resp == nil {
return []string{}, fmt.Errorf("No InstanceResp returned")
return []string{}, fmt.Errorf("no InstanceResp returned")
}
re, err := regexp.Compile(regex)

View File

@@ -78,7 +78,7 @@ func getProjectAndZone() (string, string, error) {
}
parts := strings.Split(result, "/")
if len(parts) != 4 {
return "", "", fmt.Errorf("Unexpected response: %s", result)
return "", "", fmt.Errorf("unexpected response: %s", result)
}
return parts[1], parts[3], nil
}
@@ -91,7 +91,7 @@ func getInstanceID() (string, error) {
}
parts := strings.Split(result, ".")
if len(parts) == 0 {
return "", fmt.Errorf("Unexpected response: %s", result)
return "", fmt.Errorf("unexpected response: %s", result)
}
return parts[0], nil
}
@@ -266,7 +266,7 @@ func (gce *GCECloud) IPAddress(instance string) (net.IP, error) {
}
ip := net.ParseIP(res.NetworkInterfaces[0].AccessConfigs[0].NatIP)
if ip == nil {
return nil, fmt.Errorf("Invalid network IP: %s", res.NetworkInterfaces[0].AccessConfigs[0].NatIP)
return nil, fmt.Errorf("invalid network IP: %s", res.NetworkInterfaces[0].AccessConfigs[0].NatIP)
}
return ip, nil
}

View File

@@ -79,7 +79,7 @@ func (cfg Config) toAuthOptions() gophercloud.AuthOptions {
func readConfig(config io.Reader) (Config, error) {
if config == nil {
err := fmt.Errorf("No OpenStack cloud provider config file given")
err := fmt.Errorf("no OpenStack cloud provider config file given")
return Config{}, err
}

View File

@@ -85,7 +85,7 @@ func InitCloudProvider(name string, configFilePath string) Interface {
cloud, err := GetCloudProvider(name, config)
if err != nil {
glog.Fatalf("Couldn't init cloud provider %q: %#v", name, err)
glog.Fatalf("Couldn't init cloud provider %q: %v", name, err)
}
if cloud == nil {
glog.Fatalf("Unknown cloud provider: %s", name)

View File

@@ -116,7 +116,7 @@ func (v *VagrantCloud) IPAddress(instance string) (net.IP, error) {
return net.ParseIP(minion.IP), nil
}
}
return nil, fmt.Errorf("Unable to find IP address for instance: %s", instance)
return nil, fmt.Errorf("unable to find IP address for instance: %s", instance)
}
// saltMinionsByRole filters a list of minions that have a matching role.