Skip to content

Commit

Permalink
Merge pull request kubernetes#2512 from thockin/cleanups
Browse files Browse the repository at this point in the history
Accumulated cleanups
  • Loading branch information
erictune committed Nov 21, 2014
2 parents c688bd4 + 95a9098 commit 9e921cc
Show file tree
Hide file tree
Showing 67 changed files with 195 additions and 197 deletions.
6 changes: 3 additions & 3 deletions cmd/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,16 @@ func podExists(c *client.Client, podNamespace string, podID string) wait.Conditi
func runReplicationControllerTest(c *client.Client) {
data, err := ioutil.ReadFile("api/examples/controller.json")
if err != nil {
glog.Fatalf("Unexpected error: %#v", err)
glog.Fatalf("Unexpected error: %v", err)
}
var controller api.ReplicationController
if err := api.Scheme.DecodeInto(data, &controller); err != nil {
glog.Fatalf("Unexpected error: %#v", err)
glog.Fatalf("Unexpected error: %v", err)
}

glog.Infof("Creating replication controllers")
if _, err := c.ReplicationControllers(api.NamespaceDefault).Create(&controller); err != nil {
glog.Fatalf("Unexpected error: %#v", err)
glog.Fatalf("Unexpected error: %v", err)
}
glog.Infof("Done creating replication controllers")

Expand Down
12 changes: 5 additions & 7 deletions contrib/enscope/enscope.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ func enscope(parent string, spec EnscopeSpec, in interface{}) (out interface{},
}
}
return o, nil
default:
return in, nil
}
return in, nil
}
Expand All @@ -146,7 +144,7 @@ func enscope(parent string, spec EnscopeSpec, in interface{}) (out interface{},

func ReadConfigData(location string) ([]byte, error) {
if len(location) == 0 {
return nil, fmt.Errorf("Location given but empty")
return nil, fmt.Errorf("location given but empty")
}

if location == "-" {
Expand All @@ -172,21 +170,21 @@ func readConfigDataFromLocation(location string) ([]byte, error) {
if strings.Index(location, "http://") == 0 || strings.Index(location, "https://") == 0 {
resp, err := http.Get(location)
if err != nil {
return nil, fmt.Errorf("Unable to access URL %s: %v\n", location, err)
return nil, fmt.Errorf("unable to access URL %s: %v\n", location, err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return nil, fmt.Errorf("Unable to read URL, server reported %d %s", resp.StatusCode, resp.Status)
return nil, fmt.Errorf("unable to read URL, server reported %d %s", resp.StatusCode, resp.Status)
}
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("Unable to read URL %s: %v\n", location, err)
return nil, fmt.Errorf("unable to read URL %s: %v\n", location, err)
}
return data, nil
} else {
data, err := ioutil.ReadFile(location)
if err != nil {
return nil, fmt.Errorf("Unable to read %s: %v\n", location, err)
return nil, fmt.Errorf("unable to read %s: %v\n", location, err)
}
return data, nil
}
Expand Down
12 changes: 6 additions & 6 deletions contrib/simplegen/simplegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func portsFromString(spec string) (servicePort int, containerPort int, err error
pieces := strings.Split(spec, ":")
if len(pieces) != 2 {
glog.Infof("Bad port spec: %s", spec)
return 0, 0, fmt.Errorf("Bad port spec: %s", spec)
return 0, 0, fmt.Errorf("bad port spec: %s", spec)
}
servicePort, err = strconv.Atoi(pieces[0])
if err != nil {
Expand Down Expand Up @@ -207,7 +207,7 @@ func portsFromString(spec string) (servicePort int, containerPort int, err error

func ReadConfigData(location string) ([]byte, error) {
if len(location) == 0 {
return nil, fmt.Errorf("Location given but empty")
return nil, fmt.Errorf("location given but empty")
}

if location == "-" {
Expand All @@ -233,21 +233,21 @@ func readConfigDataFromLocation(location string) ([]byte, error) {
if strings.Index(location, "http://") == 0 || strings.Index(location, "https://") == 0 {
resp, err := http.Get(location)
if err != nil {
return nil, fmt.Errorf("Unable to access URL %s: %v\n", location, err)
return nil, fmt.Errorf("unable to access URL %s: %v\n", location, err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return nil, fmt.Errorf("Unable to read URL, server reported %d %s", resp.StatusCode, resp.Status)
return nil, fmt.Errorf("unable to read URL, server reported %d %s", resp.StatusCode, resp.Status)
}
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("Unable to read URL %s: %v\n", location, err)
return nil, fmt.Errorf("unable to read URL %s: %v\n", location, err)
}
return data, nil
} else {
data, err := ioutil.ReadFile(location)
if err != nil {
return nil, fmt.Errorf("Unable to read %s: %v\n", location, err)
return nil, fmt.Errorf("unable to read %s: %v\n", location, err)
}
return data, nil
}
Expand Down
12 changes: 6 additions & 6 deletions contrib/srvexpand/srvexpand.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func portsFromString(spec string) (servicePort int, containerPort int, err error
pieces := strings.Split(spec, ":")
if len(pieces) != 2 {
glog.Infof("Bad port spec: %s", spec)
return 0, 0, fmt.Errorf("Bad port spec: %s", spec)
return 0, 0, fmt.Errorf("bad port spec: %s", spec)
}
servicePort, err = strconv.Atoi(pieces[0])
if err != nil {
Expand Down Expand Up @@ -266,7 +266,7 @@ func portsFromString(spec string) (servicePort int, containerPort int, err error

func ReadConfigData(location string) ([]byte, error) {
if len(location) == 0 {
return nil, fmt.Errorf("Location given but empty")
return nil, fmt.Errorf("location given but empty")
}

if location == "-" {
Expand All @@ -292,21 +292,21 @@ func readConfigDataFromLocation(location string) ([]byte, error) {
if strings.Index(location, "http://") == 0 || strings.Index(location, "https://") == 0 {
resp, err := http.Get(location)
if err != nil {
return nil, fmt.Errorf("Unable to access URL %s: %v\n", location, err)
return nil, fmt.Errorf("unable to access URL %s: %v\n", location, err)
}
defer resp.Body.Close()
if resp.StatusCode != 200 {
return nil, fmt.Errorf("Unable to read URL, server reported %d %s", resp.StatusCode, resp.Status)
return nil, fmt.Errorf("unable to read URL, server reported %d %s", resp.StatusCode, resp.Status)
}
data, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("Unable to read URL %s: %v\n", location, err)
return nil, fmt.Errorf("unable to read URL %s: %v\n", location, err)
}
return data, nil
} else {
data, err := ioutil.ReadFile(location)
if err != nil {
return nil, fmt.Errorf("Unable to read %s: %v\n", location, err)
return nil, fmt.Errorf("unable to read %s: %v\n", location, err)
}
return data, nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func NewConflict(kind, name string, err error) error {
Kind: kind,
ID: name,
},
Message: fmt.Sprintf("%s %q cannot be updated: %s", kind, name, err),
Message: fmt.Sprintf("%s %q cannot be updated: %v", kind, name, err),
}}
}

Expand All @@ -124,7 +124,7 @@ func NewInvalid(kind, name string, errs ValidationErrorList) error {
ID: name,
Causes: causes,
},
Message: fmt.Sprintf("%s %q is invalid: %s", kind, name, errs.ToError()),
Message: fmt.Sprintf("%s %q is invalid: %v", kind, name, errs.ToError()),
}}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/api/meta/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func (a genericAccessor) SetSelfLink(selfLink string) {
func fieldPtr(v reflect.Value, fieldName string, dest interface{}) error {
field := v.FieldByName(fieldName)
if !field.IsValid() {
return fmt.Errorf("Couldn't find %v field in %#v", fieldName, v.Interface())
return fmt.Errorf("couldn't find %v field in %#v", fieldName, v.Interface())
}
v, err := conversion.EnforcePtr(dest)
if err != nil {
Expand All @@ -309,7 +309,7 @@ func fieldPtr(v reflect.Value, fieldName string, dest interface{}) error {
v.Set(field.Convert(v.Type()))
return nil
}
return fmt.Errorf("Couldn't assign/convert %v to %v", field.Type(), v.Type())
return fmt.Errorf("couldn't assign/convert %v to %v", field.Type(), v.Type())
}

// extractFromTypeMeta extracts pointers to version and kind fields from an object
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/meta/restmapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestRESTMapperVersionAndKindForResource(t *testing.T) {
v, k, err := mapper.VersionAndKindForResource(testCase.Resource)
hasErr := err != nil
if hasErr != testCase.Err {
t.Errorf("%d: unexpected error behavior %f: %v", i, testCase.Err, err)
t.Errorf("%d: unexpected error behavior %t: %v", i, testCase.Err, err)
continue
}
if v != testCase.APIVersion || k != testCase.Kind {
Expand Down Expand Up @@ -147,7 +147,7 @@ func TestRESTMapperRESTMapping(t *testing.T) {
mapping, err := mapper.RESTMapping(testCase.APIVersion, testCase.Kind)
hasErr := err != nil
if hasErr != testCase.Err {
t.Errorf("%d: unexpected error behavior %f: %v", i, testCase.Err, err)
t.Errorf("%d: unexpected error behavior %t: %v", i, testCase.Err, err)
}
if hasErr {
continue
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ type Status struct {
// "Failure" or "Working" status. If this value is empty there
// is no information available. A Reason clarifies an HTTP status
// code but does not override it.
Reason StatusReason `json:"reason,omitempty" yaml:"reason,omitempty" description:"machine-readable description of why this operation is in the "Failure" or "Working" status; if this value is empty there is no information available; a reason clarifies an HTTP status code but does not override it"`
Reason StatusReason `json:"reason,omitempty" yaml:"reason,omitempty" description:"machine-readable description of why this operation is in the 'Failure' or 'Working' status; if this value is empty there is no information available; a reason clarifies an HTTP status code but does not override it"`
// Extended data associated with the reason. Each reason may define its
// own extended details. This field is optional and the data returned
// is not guaranteed to conform to any schema except that defined by
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/v1beta2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ type Status struct {
// "Failure" or "Working" status. If this value is empty there
// is no information available. A Reason clarifies an HTTP status
// code but does not override it.
Reason StatusReason `json:"reason,omitempty" yaml:"reason,omitempty" description:"machine-readable description of why this operation is in the "Failure" or "Working" status; if this value is empty there is no information available; a reason clarifies an HTTP status code but does not override it"`
Reason StatusReason `json:"reason,omitempty" yaml:"reason,omitempty" description:"machine-readable description of why this operation is in the 'Failure' or 'Working' status; if this value is empty there is no information available; a reason clarifies an HTTP status code but does not override it"`
// Extended data associated with the reason. Each reason may define its
// own extended details. This field is optional and the data returned
// is not guaranteed to conform to any schema except that defined by
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func ValidateService(service *api.Service, lister ServiceLister, ctx api.Context
if services.Items[i].Name != service.Name &&
services.Items[i].Spec.CreateExternalLoadBalancer &&
services.Items[i].Spec.Port == service.Spec.Port {
allErrs = append(allErrs, errs.NewConflict("service", service.Name, fmt.Errorf("Port: %d is already in use", service.Spec.Port)))
allErrs = append(allErrs, errs.NewConflict("service", service.Name, fmt.Errorf("port: %d is already in use", service.Spec.Port)))
break
}
}
Expand Down Expand Up @@ -548,7 +548,7 @@ func ValidateMinionUpdate(oldMinion *api.Minion, minion *api.Minion) errs.Valida
oldMinion.Labels = minion.Labels
oldMinion.ObjectMeta.Labels = minion.ObjectMeta.Labels
if !reflect.DeepEqual(oldMinion, minion) {
allErrs = append(allErrs, fmt.Errorf("Update contains more than labels changes"))
allErrs = append(allErrs, fmt.Errorf("update contains more than labels changes"))
}
return allErrs
}
2 changes: 1 addition & 1 deletion pkg/api/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ func TestValidateService(t *testing.T) {
registry.List = tc.existing
errs := ValidateService(&tc.svc, registry, api.NewDefaultContext())
if len(errs) != tc.numErrs {
t.Errorf("Unexpected error list for case %q: %+v", tc.name, errs)
t.Errorf("Unexpected error list for case %q: %v", tc.name, errs.ToError())
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func parseTimeout(str string) time.Duration {
if err == nil {
return timeout
}
glog.Errorf("Failed to parse: %#v '%s'", err, str)
glog.Errorf("Failed to parse %q: %v", str, err)
}
return 30 * time.Second
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apiserver/apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func TestNotFound(t *testing.T) {
}

if response.StatusCode != v.Status {
t.Errorf("Expected %d for %s (%s), Got %#v", v.Status, v, k, response)
t.Errorf("Expected %d for %s (%s), Got %#v", v.Status, v.Method, k, response)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (c *Client) ServerVersion() (*version.Info, error) {
var info version.Info
err = json.Unmarshal(body, &info)
if err != nil {
return nil, fmt.Errorf("Got '%s': %v", string(body), err)
return nil, fmt.Errorf("got '%s': %v", string(body), err)
}
return &info, nil
}
Expand All @@ -100,7 +100,7 @@ func (c *Client) ServerAPIVersions() (*api.APIVersions, error) {
var v api.APIVersions
err = json.Unmarshal(body, &v)
if err != nil {
return nil, fmt.Errorf("Got '%s': %v", string(body), err)
return nil, fmt.Errorf("got '%s': %v", string(body), err)
}
return &v, nil
}
4 changes: 2 additions & 2 deletions pkg/client/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func (r *Request) Body(obj interface{}) *Request {
}
r.body = bytes.NewBuffer(data)
default:
r.err = fmt.Errorf("Unknown type used for body: %#v", obj)
r.err = fmt.Errorf("unknown type used for body: %#v", obj)
}
return r
}
Expand Down Expand Up @@ -305,7 +305,7 @@ func (r *Request) Watch() (watch.Interface, error) {
if resp.Body != nil {
body, _ = ioutil.ReadAll(resp.Body)
}
return nil, fmt.Errorf("For request '%v', got status: %v\nbody: %v", req.URL, resp.StatusCode, string(body))
return nil, fmt.Errorf("for request '%v', got status: %v\nbody: %v", req.URL, resp.StatusCode, string(body))
}
return watch.NewStreamWatcher(watchjson.NewDecoder(resp.Body, r.codec)), nil
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/client/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ func TestTransformResponse(t *testing.T) {
response, created, err := r.transformResponse(test.Response, &http.Request{})
hasErr := err != nil
if hasErr != test.Error {
t.Errorf("%d: unexpected error: %f %v", i, test.Error, err)
t.Errorf("%d: unexpected error: %t %v", i, test.Error, err)
}
if !(test.Data == nil && response == nil) && !reflect.DeepEqual(test.Data, response) {
t.Errorf("%d: unexpected response: %#v %#v", i, test.Data, response)
}
if test.Created != created {
t.Errorf("%d: expected created %f, got %f", i, test.Created, created)
t.Errorf("%d: expected created %t, got %t", i, test.Created, created)
}
}
}
Expand Down Expand Up @@ -196,7 +196,7 @@ func TestRequestWatch(t *testing.T) {
watch, err := testCase.Request.Watch()
hasErr := err != nil
if hasErr != testCase.Err {
t.Errorf("%d: expected %f, got %f: %v", i, testCase.Err, hasErr, err)
t.Errorf("%d: expected %t, got %t: %v", i, testCase.Err, hasErr, err)
}
if hasErr && watch != nil {
t.Errorf("%d: watch should be nil when error is returned", i)
Expand Down Expand Up @@ -231,7 +231,7 @@ func TestRequestStream(t *testing.T) {
body, err := testCase.Request.Stream()
hasErr := err != nil
if hasErr != testCase.Err {
t.Errorf("%d: expected %f, got %f: %v", i, testCase.Err, hasErr, err)
t.Errorf("%d: expected %t, got %t: %v", i, testCase.Err, hasErr, err)
}
if hasErr && body != nil {
t.Errorf("%d: body should be nil when error is returned", i)
Expand Down Expand Up @@ -266,7 +266,7 @@ func TestRequestDo(t *testing.T) {
body, err := testCase.Request.Do().Raw()
hasErr := err != nil
if hasErr != testCase.Err {
t.Errorf("%d: expected %f, got %f: %v", i, testCase.Err, hasErr, err)
t.Errorf("%d: expected %t, got %t: %v", i, testCase.Err, hasErr, err)
}
if hasErr && body != nil {
t.Errorf("%d: body should be nil when error is returned", i)
Expand Down
Loading

0 comments on commit 9e921cc

Please sign in to comment.