Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'go vet' issues #1637

Merged
merged 6 commits into from
Oct 7, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ type TypeMeta struct {
SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"`
ResourceVersion uint64 `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"`
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
Namespace string `json:"namespace",omitempty" yaml:"namespace,omitempty"`
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
UID string `json:"uid,omitempty" yaml:"uid,omitempty"`

// Annotations are unstructured key value data stored with a resource that may be set by
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 @@ -262,7 +262,7 @@ type TypeMeta struct {
SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"`
ResourceVersion uint64 `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"`
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
Namespace string `json:"namespace",omitempty" yaml:"namespace,omitempty"`
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`

// Annotations are unstructured key value data stored with a resource that may be set by
// external tooling. They are not queryable and should be preserved when modifying
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 @@ -260,7 +260,7 @@ type TypeMeta struct {
SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"`
ResourceVersion uint64 `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"`
APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"`
Namespace string `json:"namespace",omitempty" yaml:"namespace,omitempty"`
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`

// Annotations are unstructured key value data stored with a resource that may be set by
// external tooling. They are not queryable and should be preserved when modifying
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (

func expectPrefix(t *testing.T, prefix string, errs errors.ErrorList) {
for i := range errs {
if !strings.HasPrefix(errs[i].(errors.ValidationError).Field, prefix) {
t.Errorf("expected prefix '%s' for %v", errs[i])
if f, p := errs[i].(errors.ValidationError).Field, prefix; !strings.HasPrefix(f, p) {
t.Errorf("expected prefix '%s' for field '%s' (%v)", p, f, errs[i])
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/kubelet/runonce.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ func (kl *Kubelet) runOnce(pods []Pod) (results []RunPodResult, err error) {
pods = filterHostPortConflicts(pods)

ch := make(chan RunPodResult)
for _, pod := range pods {
for i := range pods {
pod := pods[i] // Make a copy
go func() {
info, err := kl.runPod(pod)
ch <- RunPodResult{&pod, info, err}
Expand Down
3 changes: 2 additions & 1 deletion pkg/proxy/config/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ import (
)

// serviceConfig is a deserialized form of the config file format which ConfigSourceFile accepts.
// TODO: this is apparently untested; is it used?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

afaik it is not used, and not very useful

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #1639 for this.

type serviceConfig struct {
Services []struct {
Name string `json: "name"`
Port int `json: "port"`
Endpoints []string `json: "endpoints"`
} `json: "service"`
} `json:"service"`
}

// ConfigSourceFile periodically reads service configurations in JSON from a file, and sends the services and endpoints defined in the file to the specified channels.
Expand Down
2 changes: 1 addition & 1 deletion pkg/registry/minion/healthy_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (r *HealthyRegistry) ListMinions(ctx api.Context) (currentMinions *api.Mini
for _, minion := range list.Items {
status, err := health.DoHTTPCheck(r.makeMinionURL(minion.ID), r.client)
if err != nil {
glog.Errorf("%s failed health check with error: %s", minion, err)
glog.Errorf("%#v failed health check with error: %s", minion, err)
continue
}
if status == health.Healthy {
Expand Down
1 change: 0 additions & 1 deletion pkg/registry/pod/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,5 +340,4 @@ func (rs *REST) waitForPodRunning(ctx api.Context, pod *api.Pod) (runtime.Object
time.Sleep(rs.podPollPeriod)
}
}
return pod, nil
}
12 changes: 9 additions & 3 deletions pkg/runtime/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ func (s *Scheme) CopyOrDie(obj Object) Object {
return newObj
}

// ObjectDiff writes the two objects out as JSON and prints out the identical part of
// the objects followed by the remaining part of 'a' and finally the remaining part of 'b'.
// For debugging tests.
func ObjectDiff(a, b Object) string {
ab, err := json.Marshal(a)
if err != nil {
Expand All @@ -378,10 +381,13 @@ func ObjectDiff(a, b Object) string {
panic(fmt.Sprintf("b: %v", err))
}
return util.StringDiff(string(ab), string(bb))
}

// An alternate diff attempt, in case json isn't showing you
// the difference. (reflect.DeepEqual makes a distinction between
// nil and empty slices, for example.)
// ObjectGoPrintDiff is like ObjectDiff, but uses go's %#v formatter to print the
// objects, in case json isn't showing you the difference. (reflect.DeepEqual makes
// a distinction between nil and empty slices, for example, even though nothing else
// really does.)
func ObjectGoPrintDiff(a, b Object) string {
return util.StringDiff(
fmt.Sprintf("%#v", a),
fmt.Sprintf("%#v", b),
Expand Down