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

Additional go vet fixes #23660

Merged
merged 1 commit into from
Apr 12, 2016
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
3 changes: 0 additions & 3 deletions api/swagger-spec/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -15627,9 +15627,6 @@
"v1.NodeStatus": {
"id": "v1.NodeStatus",
"description": "NodeStatus is information about the current status of a node.",
"required": [
"images"
],
"properties": {
"capacity": {
"type": "any",
Expand Down
5 changes: 2 additions & 3 deletions cmd/libs/go2idl/go-to-protobuf/protobuf/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ func (g *genProtoIDL) GenerateType(c *generator.Context, t *types.Type, w io.Wri
default:
return b.unknown(sw)
}
return sw.Error()
}

// ProtobufFromGoNamer finds the protobuf name of a type (and its package, and
Expand Down Expand Up @@ -424,7 +423,7 @@ func memberTypeToProtobufField(locator ProtobufLocator, field *protoField, t *ty
field.Nullable = true
case types.Alias:
if err := memberTypeToProtobufField(locator, field, t.Underlying); err != nil {
log.Printf("failed to alias: %s %s: err", t.Name, t.Underlying.Name, err)
log.Printf("failed to alias: %s %s: err %v", t.Name, t.Underlying.Name, err)
return err
}
if field.Extras == nil {
Expand Down Expand Up @@ -594,7 +593,7 @@ func membersToFields(locator ProtobufLocator, t *types.Type, localPackage types.
tag := field.Tag
if tag != -1 {
if existing, ok := byTag[tag]; ok {
return nil, fmt.Errorf("field %q and %q in %q both have tag %d", field.Name, existing.Name, tag)
return nil, fmt.Errorf("field %q and %q both have tag %d", field.Name, existing.Name, tag)
}
byTag[tag] = field
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/libs/go2idl/parser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ var FooAnotherVar proto.Frobber = proto.AnotherVar
t.Errorf("Wanted, got:\n%v\n-----\n%v\n", e, a)
}
if p := u.Package("base/foo/proto"); !p.HasImport("base/common/proto") {
t.Errorf("Unexpected lack of import line: %#s", p.Imports)
t.Errorf("Unexpected lack of import line: %s", p.Imports)
}
}

Expand Down
2 changes: 1 addition & 1 deletion contrib/mesos/pkg/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ func (k *Executor) bindAndWatchTask(driver bindings.ExecutorDriver, task *mesos.
// within the launch timeout window we should see a pod-task update via the registry.
// if we see a Running update then we need to generate a TASK_RUNNING status update for mesos.
handlerFinished := false
handler := watchHandler{
handler := &watchHandler{
expiration: watchExpiration{
timeout: launchTimer.C,
onEvent: func(taskID string) {
Expand Down
15 changes: 7 additions & 8 deletions contrib/mesos/pkg/executor/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func NewRegistry(client *clientset.Clientset) Registry {
return r
}

func (r registryImpl) watch() <-chan *PodEvent {
func (r *registryImpl) watch() <-chan *PodEvent {
return r.updates
}

Expand All @@ -130,26 +130,26 @@ func taskIDFor(pod *api.Pod) (taskID string, err error) {
return
}

func (r registryImpl) shutdown() {
func (r *registryImpl) shutdown() {
//TODO(jdef) flesh this out
r.m.Lock()
defer r.m.Unlock()
r.boundTasks = map[string]*api.Pod{}
}

func (r registryImpl) empty() bool {
func (r *registryImpl) empty() bool {
r.m.RLock()
defer r.m.RUnlock()
return len(r.boundTasks) == 0
}

func (r registryImpl) pod(taskID string) *api.Pod {
func (r *registryImpl) pod(taskID string) *api.Pod {
r.m.RLock()
defer r.m.RUnlock()
return r.boundTasks[taskID]
}

func (r registryImpl) Remove(taskID string) error {
func (r *registryImpl) Remove(taskID string) error {
r.m.Lock()
defer r.m.Unlock()
pod, ok := r.boundTasks[taskID]
Expand All @@ -169,7 +169,7 @@ func (r registryImpl) Remove(taskID string) error {
return nil
}

func (r registryImpl) Update(pod *api.Pod) (*PodEvent, error) {
func (r *registryImpl) Update(pod *api.Pod) (*PodEvent, error) {
// Don't do anything for pods without task anotation which means:
// - "pre-scheduled" pods which have a NodeName set to this node without being scheduled already.
// - static/mirror pods: they'll never have a TaskID annotation, and we don't expect them to ever change.
Expand Down Expand Up @@ -254,8 +254,7 @@ func copyPorts(dest, src *api.Pod) bool {
return true
}

func (r registryImpl) bind(taskID string, pod *api.Pod) error {

func (r *registryImpl) bind(taskID string, pod *api.Pod) error {
// validate taskID matches that of the annotation
annotatedTaskID, err := taskIDFor(pod)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions contrib/mesos/pkg/executor/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type (
watcher struct {
updates <-chan *PodEvent
rw sync.RWMutex
handlers map[string]watchHandler
handlers map[string]*watchHandler
filters []watchFilter
runOnce chan struct{}
}
Expand All @@ -64,7 +64,7 @@ type (
func newWatcher(updates <-chan *PodEvent) *watcher {
return &watcher{
updates: updates,
handlers: make(map[string]watchHandler),
handlers: make(map[string]*watchHandler),
runOnce: make(chan struct{}),
}
}
Expand All @@ -86,7 +86,7 @@ updateLoop:
}
}
log.V(1).Info("handling " + u.FormatShort())
h, ok := func() (h watchHandler, ok bool) {
h, ok := func() (h *watchHandler, ok bool) {
pw.rw.RLock()
defer pw.rw.RUnlock()
h, ok = pw.handlers[u.taskID]
Expand Down Expand Up @@ -125,7 +125,7 @@ func (pw *watcher) addFilter(f watchFilter) {
}

// forTask associates a handler `h` with the given taskID.
func (pw *watcher) forTask(taskID string, h watchHandler) {
func (pw *watcher) forTask(taskID string, h *watchHandler) {
pw.rw.Lock()
pw.handlers[taskID] = h
pw.rw.Unlock()
Expand Down
4 changes: 2 additions & 2 deletions docs/api-reference/v1/definitions.html
Original file line number Diff line number Diff line change
Expand Up @@ -4492,7 +4492,7 @@ <h3 id="_v1_nodestatus">v1.NodeStatus</h3>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">images</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">List of container images on this node</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">false</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><a href="#_v1_containerimage">v1.ContainerImage</a> array</p></td>
<td class="tableblock halign-left valign-top"></td>
</tr>
Expand Down Expand Up @@ -7780,7 +7780,7 @@ <h3 id="_any">any</h3>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2016-03-21 22:46:36 UTC
Last updated 2016-04-06 18:15:59 UTC
</div>
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/errors/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func InterpretWatchError(err error, resource unversioned.GroupResource, name str
switch {
case storage.IsInvalidError(err):
invalidError, _ := err.(storage.InvalidError)
return errors.NewInvalid(unversioned.GroupKind{resource.Group, resource.Resource}, name, invalidError.Errs)
return errors.NewInvalid(unversioned.GroupKind{Group: resource.Group, Kind: resource.Resource}, name, invalidError.Errs)
default:
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/rest/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func BeforeDelete(strategy RESTDeleteStrategy, ctx api.Context, obj runtime.Obje
}
// Checking the Preconditions here to fail early. They'll be enforced later on when we actually do the deletion, too.
if options.Preconditions != nil && options.Preconditions.UID != nil && *options.Preconditions.UID != objectMeta.UID {
return false, false, errors.NewConflict(unversioned.GroupResource{gvk.Group, gvk.Kind}, objectMeta.Name, fmt.Errorf("the UID in the precondition (%s) does not match the UID in record (%s). The object might have been deleted and then recreated", *options.Preconditions.UID, objectMeta.UID))
return false, false, errors.NewConflict(unversioned.GroupResource{Group: gvk.Group, Resource: gvk.Kind}, objectMeta.Name, fmt.Errorf("the UID in the precondition (%s) does not match the UID in record (%s). The object might have been deleted and then recreated", *options.Preconditions.UID, objectMeta.UID))
}
gracefulStrategy, ok := strategy.(RESTGracefulDeleteStrategy)
if !ok {
Expand Down
43 changes: 25 additions & 18 deletions pkg/api/types.generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -33273,11 +33273,12 @@ func (x *NodeStatus) CodecEncodeSelf(e *codec1978.Encoder) {
yyq2[4] = len(x.Addresses) != 0
yyq2[5] = true
yyq2[6] = true
yyq2[7] = len(x.Images) != 0
var yynn2 int
if yyr2 || yy2arr2 {
r.EncodeArrayStart(8)
} else {
yynn2 = 1
yynn2 = 0
for _, b := range yyq2 {
if b {
yynn2++
Expand Down Expand Up @@ -33449,28 +33450,34 @@ func (x *NodeStatus) CodecEncodeSelf(e *codec1978.Encoder) {
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if x.Images == nil {
r.EncodeNil()
} else {
yym29 := z.EncBinary()
_ = yym29
if false {
if yyq2[7] {
if x.Images == nil {
r.EncodeNil()
} else {
h.encSliceContainerImage(([]ContainerImage)(x.Images), e)
yym29 := z.EncBinary()
_ = yym29
if false {
} else {
h.encSliceContainerImage(([]ContainerImage)(x.Images), e)
}
}
} else {
r.EncodeNil()
}
} else {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("images"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.Images == nil {
r.EncodeNil()
} else {
yym30 := z.EncBinary()
_ = yym30
if false {
if yyq2[7] {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("images"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.Images == nil {
r.EncodeNil()
} else {
h.encSliceContainerImage(([]ContainerImage)(x.Images), e)
yym30 := z.EncBinary()
_ = yym30
if false {
} else {
h.encSliceContainerImage(([]ContainerImage)(x.Images), e)
}
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1671,8 +1671,14 @@ type NodeSpec struct {

// DaemonEndpoint contains information about a single Daemon endpoint.
type DaemonEndpoint struct {
/*
The port tag was not properly in quotes in earlier releases, so it must be
uppercased for backwards compat (since it was falling back to var name of
'Port').
*/

// Port number of the given endpoint.
Port int `json:port`
Port int `json:"Port"`
}

// NodeDaemonEndpoints lists ports opened by daemons running on the Node.
Expand Down Expand Up @@ -1718,7 +1724,7 @@ type NodeStatus struct {
// Set of ids/uuids to uniquely identify the node.
NodeInfo NodeSystemInfo `json:"nodeInfo,omitempty"`
// List of container images on this node
Images []ContainerImage `json:"images",omitempty`
Images []ContainerImage `json:"images,omitempty"`
}

// Describe a container image
Expand Down
43 changes: 25 additions & 18 deletions pkg/api/v1/types.generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -33155,11 +33155,12 @@ func (x *NodeStatus) CodecEncodeSelf(e *codec1978.Encoder) {
yyq2[4] = len(x.Addresses) != 0
yyq2[5] = true
yyq2[6] = true
yyq2[7] = len(x.Images) != 0
var yynn2 int
if yyr2 || yy2arr2 {
r.EncodeArrayStart(8)
} else {
yynn2 = 1
yynn2 = 0
for _, b := range yyq2 {
if b {
yynn2++
Expand Down Expand Up @@ -33331,28 +33332,34 @@ func (x *NodeStatus) CodecEncodeSelf(e *codec1978.Encoder) {
}
if yyr2 || yy2arr2 {
z.EncSendContainerState(codecSelfer_containerArrayElem1234)
if x.Images == nil {
r.EncodeNil()
} else {
yym29 := z.EncBinary()
_ = yym29
if false {
if yyq2[7] {
if x.Images == nil {
r.EncodeNil()
} else {
h.encSliceContainerImage(([]ContainerImage)(x.Images), e)
yym29 := z.EncBinary()
_ = yym29
if false {
} else {
h.encSliceContainerImage(([]ContainerImage)(x.Images), e)
}
}
} else {
r.EncodeNil()
}
} else {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("images"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.Images == nil {
r.EncodeNil()
} else {
yym30 := z.EncBinary()
_ = yym30
if false {
if yyq2[7] {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("images"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
if x.Images == nil {
r.EncodeNil()
} else {
h.encSliceContainerImage(([]ContainerImage)(x.Images), e)
yym30 := z.EncBinary()
_ = yym30
if false {
} else {
h.encSliceContainerImage(([]ContainerImage)(x.Images), e)
}
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions pkg/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2047,8 +2047,14 @@ type NodeSpec struct {

// DaemonEndpoint contains information about a single Daemon endpoint.
type DaemonEndpoint struct {
/*
The port tag was not properly in quotes in earlier releases, so it must be
uppercased for backwards compat (since it was falling back to var name of
'Port').
*/

// Port number of the given endpoint.
Port int32 `json:port`
Port int32 `json:"Port"`
}

// NodeDaemonEndpoints lists ports opened by daemons running on the Node.
Expand Down Expand Up @@ -2101,7 +2107,7 @@ type NodeStatus struct {
// More info: http://releases.k8s.io/HEAD/docs/admin/node.md#node-info
NodeInfo NodeSystemInfo `json:"nodeInfo,omitempty"`
// List of container images on this node
Images []ContainerImage `json:"images",omitempty`
Images []ContainerImage `json:"images,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

This is probably ok.

}

// Describe a container image
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/componentconfig/types.generated.go
Original file line number Diff line number Diff line change
Expand Up @@ -2048,7 +2048,7 @@ func (x *KubeletConfiguration) CodecEncodeSelf(e *codec1978.Encoder) {
}
} else {
z.EncSendContainerState(codecSelfer_containerMapKey1234)
r.EncodeString(codecSelferC_UTF81234, string("VolumeStatsAggPeriod"))
r.EncodeString(codecSelferC_UTF81234, string("volumeStatsAggPeriod"))
z.EncSendContainerState(codecSelfer_containerMapValue1234)
yy149 := &x.VolumeStatsAggPeriod
yym150 := z.EncBinary()
Expand Down Expand Up @@ -3190,7 +3190,7 @@ func (x *KubeletConfiguration) codecDecodeSelfFromMap(l int, d *codec1978.Decode
} else {
x.LowDiskSpaceThresholdMB = int(r.DecodeInt(codecSelferBitsize1234))
}
case "VolumeStatsAggPeriod":
case "volumeStatsAggPeriod":
if r.TryDecodeAsNil() {
x.VolumeStatsAggPeriod = pkg1_unversioned.Duration{}
} else {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/componentconfig/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ type KubeletConfiguration struct {
// be rejected.
LowDiskSpaceThresholdMB int `json:"lowDiskSpaceThresholdMB"`
// How frequently to calculate and cache volume disk usage for all pods
VolumeStatsAggPeriod unversioned.Duration `json:volumeStatsAggPeriod`
VolumeStatsAggPeriod unversioned.Duration `json:"volumeStatsAggPeriod"`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@krousey Does this need to be uppercased for backcompat too?

Copy link
Contributor

Choose a reason for hiding this comment

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

For this one, I'm not sure. It doesn't seem like a normal API type, but if it's user visible, I would imagine so. Again, I defer to @bgrant0607 on these.

Copy link
Member

Choose a reason for hiding this comment

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

@mikedanese Is anyone using these types yet?

Clearly we need a checker for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

@bgrant0607 This is what @goltermann is working torwards... as soon as we get the current codebase go vet clean, he will turn it on by default.

Copy link
Member

Choose a reason for hiding this comment

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

Change looks good to me. Lower case is consistent with the rest of the file so I would leave it. This is not used yet and IIUC json tags aren't necessary in the internal types.go so we may remove them later. Thanks!

// networkPluginName is the name of the network plugin to be invoked for
// various events in kubelet/pod lifecycle
NetworkPluginName string `json:"networkPluginName"`
Expand Down