Verify and fix error message nit :)

This commit is contained in:
Rohit Jnagal 2015-01-14 01:15:13 +00:00
parent 57c6fb08f4
commit ed155019ac
8 changed files with 46 additions and 18 deletions

View File

@ -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

28
hooks/check_errorf.sh Executable file
View File

@ -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

View File

@ -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.

View File

@ -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)

View File

@ -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 {

View File

@ -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{}

View File

@ -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) {

View File

@ -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