diff --git a/container/docker/factory.go b/container/docker/factory.go index 07b414bc..cf7e1764 100644 --- a/container/docker/factory.go +++ b/container/docker/factory.go @@ -208,7 +208,7 @@ func Register(factory info.MachineInfoFactory) error { } } if !usesNativeDriver { - return fmt.Errorf("Docker found, but not using native exec driver") + return fmt.Errorf("docker found, but not using native exec driver") } usesAufsDriver := false diff --git a/hooks/check_errorf.sh b/hooks/check_errorf.sh new file mode 100755 index 00000000..f9259c95 --- /dev/null +++ b/hooks/check_errorf.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Copyright 2015 Google Inc. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +GO_FILES=$(find . -not -wholename "*Godeps*" -name "*.go") + +for FILE in ${GO_FILES}; do + ERRS=`grep 'fmt.Errorf("[A-Z]' ${FILE}` + if [ $? -eq 0 ] + then + echo Incorrect error format in file ${FILE}: $ERRS + exit 1 + fi +done + +exit 0 diff --git a/manager/manager.go b/manager/manager.go index bf9fa871..aebcdc25 100644 --- a/manager/manager.go +++ b/manager/manager.go @@ -514,7 +514,7 @@ func (self *manager) watchForNewContainers(quit chan error) error { }] }() if !ok { - return fmt.Errorf("Root container does not exist when watching for new containers") + return fmt.Errorf("root container does not exist when watching for new containers") } // Register for new subcontainers. diff --git a/pages/containers.go b/pages/containers.go index 44a50eea..574b415f 100644 --- a/pages/containers.go +++ b/pages/containers.go @@ -185,7 +185,7 @@ func serveContainersPage(m manager.Manager, w http.ResponseWriter, u *url.URL) e } cont, err := m.GetContainerInfo(containerName, &reqParams) if err != nil { - return fmt.Errorf("Failed to get container %q with error: %v", containerName, err) + return fmt.Errorf("failed to get container %q with error: %v", containerName, err) } displayName := getContainerDisplayName(cont.ContainerReference) diff --git a/pages/docker.go b/pages/docker.go index 594b12a1..f14fd6f2 100644 --- a/pages/docker.go +++ b/pages/docker.go @@ -43,7 +43,7 @@ func serveDockerPage(m manager.Manager, w http.ResponseWriter, u *url.URL) error } conts, err := m.AllDockerContainers(&reqParams) if err != nil { - return fmt.Errorf("Failed to get container %q with error: %v", containerName, err) + return fmt.Errorf("failed to get container %q with error: %v", containerName, err) } subcontainers := make([]link, 0, len(conts)) for _, cont := range conts { diff --git a/storage/bigquery/client/client.go b/storage/bigquery/client/client.go index e509502c..8ead5000 100644 --- a/storage/bigquery/client/client.go +++ b/storage/bigquery/client/client.go @@ -50,21 +50,21 @@ type Client struct { // Helper method to create an authenticated connection. func connect() (*oauth.Token, *bigquery.Service, error) { if *clientId == "" { - return nil, nil, fmt.Errorf("No client id specified") + return nil, nil, fmt.Errorf("no client id specified") } if *serviceAccount == "" { - return nil, nil, fmt.Errorf("No service account specified") + return nil, nil, fmt.Errorf("no service account specified") } if *projectId == "" { - return nil, nil, fmt.Errorf("No project id specified") + return nil, nil, fmt.Errorf("no project id specified") } authScope := bigquery.BigqueryScope if *pemFile == "" { - return nil, nil, fmt.Errorf("No credentials specified") + return nil, nil, fmt.Errorf("no credentials specified") } pemBytes, err := ioutil.ReadFile(*pemFile) if err != nil { - return nil, nil, fmt.Errorf("Could not access credential file %v - %v", pemFile, err) + return nil, nil, fmt.Errorf("could not access credential file %v - %v", pemFile, err) } t := jwt.NewToken(*serviceAccount, authScope, pemBytes) @@ -118,7 +118,7 @@ func (c *Client) Close() error { // Expired connection is refreshed. func (c *Client) getService() (*bigquery.Service, error) { if c.token == nil || c.service == nil { - return nil, fmt.Errorf("Service not initialized") + return nil, fmt.Errorf("service not initialized") } // Refresh expired token. @@ -151,7 +151,7 @@ func (c *Client) PrintDatasets() error { func (c *Client) CreateDataset(datasetId string) error { if c.service == nil { - return fmt.Errorf("No service created") + return fmt.Errorf("no service created") } _, err := c.service.Datasets.Insert(*projectId, &bigquery.Dataset{ DatasetReference: &bigquery.DatasetReference{ @@ -171,7 +171,7 @@ func (c *Client) CreateDataset(datasetId string) error { // Schema is currently not updated if the table already exists. func (c *Client) CreateTable(tableId string, schema *bigquery.TableSchema) error { if c.service == nil || c.datasetId == "" { - return fmt.Errorf("No dataset created") + return fmt.Errorf("no dataset created") } _, err := c.service.Tables.Get(*projectId, c.datasetId, tableId).Do() if err != nil { @@ -197,7 +197,7 @@ func (c *Client) CreateTable(tableId string, schema *bigquery.TableSchema) error func (c *Client) InsertRow(rowData map[string]interface{}) error { service, _ := c.getService() if service == nil || c.datasetId == "" || c.tableId == "" { - return fmt.Errorf("Table not setup to add rows") + return fmt.Errorf("table not setup to add rows") } jsonRows := make(map[string]bigquery.JsonValue) for key, value := range rowData { @@ -214,7 +214,7 @@ func (c *Client) InsertRow(rowData map[string]interface{}) error { result, err := service.Tabledata.InsertAll(*projectId, c.datasetId, c.tableId, insertRequest).Do() if err != nil { - return fmt.Errorf("Error inserting row: %v", err) + return fmt.Errorf("error inserting row: %v", err) } if len(result.InsertErrors) > 0 { @@ -232,7 +232,7 @@ func (c *Client) InsertRow(rowData map[string]interface{}) error { // Returns a bigtable table name (format: datasetID.tableID) func (c *Client) GetTableName() (string, error) { if c.service == nil || c.datasetId == "" || c.tableId == "" { - return "", fmt.Errorf("Table not setup") + return "", fmt.Errorf("table not setup") } return fmt.Sprintf("%s.%s", c.datasetId, c.tableId), nil } @@ -262,7 +262,7 @@ func (c *Client) Query(query string) ([]string, [][]interface{}, error) { } numRows := results.TotalRows if numRows < 1 { - return nil, nil, fmt.Errorf("Query returned no data") + return nil, nil, fmt.Errorf("query returned no data") } headers := []string{} diff --git a/storage/influxdb/influxdb.go b/storage/influxdb/influxdb.go index 227cca0b..8dc90758 100644 --- a/storage/influxdb/influxdb.go +++ b/storage/influxdb/influxdb.go @@ -169,7 +169,7 @@ func convertToUint64(v interface{}) (uint64, error) { case uint32: return uint64(x), nil } - return 0, fmt.Errorf("Unknown type") + return 0, fmt.Errorf("unknown type") } func (self *influxdbStorage) valuesToContainerStats(columns []string, values []interface{}) (*info.ContainerStats, error) { diff --git a/storagedriver.go b/storagedriver.go index 443aac7d..d784d579 100644 --- a/storagedriver.go +++ b/storagedriver.go @@ -81,7 +81,7 @@ func NewStorageDriver(driverName string) (*memory.InMemoryStorage, error) { ) default: - err = fmt.Errorf("Unknown database driver: %v", *argDbDriver) + err = fmt.Errorf("unknown database driver: %v", *argDbDriver) } if err != nil { return nil, err