Correcting all go vet errors
This commit is contained in:
@@ -38,7 +38,7 @@ func newSourceApiserverFromLW(lw cache.ListerWatcher, updates chan<- interface{}
|
||||
for _, o := range objs {
|
||||
pods = append(pods, o.(*api.Pod))
|
||||
}
|
||||
updates <- kubelet.PodUpdate{pods, kubelet.SET, kubelet.ApiserverSource}
|
||||
updates <- kubelet.PodUpdate{Pods: pods, Op: kubelet.SET, Source: kubelet.ApiserverSource}
|
||||
}
|
||||
cache.NewReflector(lw, &api.Pod{}, cache.NewUndeltaStore(send, cache.MetaNamespaceKeyFunc), 0).Run()
|
||||
}
|
||||
|
@@ -170,12 +170,12 @@ func (s *podStorage) Merge(source string, change interface{}) error {
|
||||
s.updates <- *updates
|
||||
}
|
||||
if len(deletes.Pods) > 0 || len(adds.Pods) > 0 {
|
||||
s.updates <- kubelet.PodUpdate{s.MergedState().([]*api.Pod), kubelet.SET, source}
|
||||
s.updates <- kubelet.PodUpdate{Pods: s.MergedState().([]*api.Pod), Op: kubelet.SET, Source: source}
|
||||
}
|
||||
|
||||
case PodConfigNotificationSnapshot:
|
||||
if len(updates.Pods) > 0 || len(deletes.Pods) > 0 || len(adds.Pods) > 0 {
|
||||
s.updates <- kubelet.PodUpdate{s.MergedState().([]*api.Pod), kubelet.SET, source}
|
||||
s.updates <- kubelet.PodUpdate{Pods: s.MergedState().([]*api.Pod), Op: kubelet.SET, Source: source}
|
||||
}
|
||||
|
||||
default:
|
||||
@@ -339,7 +339,7 @@ func filterInvalidPods(pods []*api.Pod, source string, recorder record.EventReco
|
||||
func (s *podStorage) Sync() {
|
||||
s.updateLock.Lock()
|
||||
defer s.updateLock.Unlock()
|
||||
s.updates <- kubelet.PodUpdate{s.MergedState().([]*api.Pod), kubelet.SET, kubelet.AllSource}
|
||||
s.updates <- kubelet.PodUpdate{Pods: s.MergedState().([]*api.Pod), Op: kubelet.SET, Source: kubelet.AllSource}
|
||||
}
|
||||
|
||||
// Object implements config.Accessor
|
||||
|
@@ -66,7 +66,7 @@ func (s *sourceFile) extractFromPath() error {
|
||||
return err
|
||||
}
|
||||
// Emit an update with an empty PodList to allow FileSource to be marked as seen
|
||||
s.updates <- kubelet.PodUpdate{[]*api.Pod{}, kubelet.SET, kubelet.FileSource}
|
||||
s.updates <- kubelet.PodUpdate{Pods: []*api.Pod{}, Op: kubelet.SET, Source: kubelet.FileSource}
|
||||
return fmt.Errorf("path does not exist, ignoring")
|
||||
}
|
||||
|
||||
@@ -76,14 +76,14 @@ func (s *sourceFile) extractFromPath() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.updates <- kubelet.PodUpdate{pods, kubelet.SET, kubelet.FileSource}
|
||||
s.updates <- kubelet.PodUpdate{Pods: pods, Op: kubelet.SET, Source: kubelet.FileSource}
|
||||
|
||||
case statInfo.Mode().IsRegular():
|
||||
pod, err := s.extractFromFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
s.updates <- kubelet.PodUpdate{[]*api.Pod{pod}, kubelet.SET, kubelet.FileSource}
|
||||
s.updates <- kubelet.PodUpdate{Pods: []*api.Pod{pod}, Op: kubelet.SET, Source: kubelet.FileSource}
|
||||
|
||||
default:
|
||||
return fmt.Errorf("path is not a directory or file")
|
||||
|
@@ -95,7 +95,7 @@ func (s *sourceURL) extractFromURL() error {
|
||||
}
|
||||
if len(data) == 0 {
|
||||
// Emit an update with an empty PodList to allow HTTPSource to be marked as seen
|
||||
s.updates <- kubelet.PodUpdate{[]*api.Pod{}, kubelet.SET, kubelet.HTTPSource}
|
||||
s.updates <- kubelet.PodUpdate{Pods: []*api.Pod{}, Op: kubelet.SET, Source: kubelet.HTTPSource}
|
||||
return fmt.Errorf("zero-length data received from %v", s.url)
|
||||
}
|
||||
// Short circuit if the data has not changed since the last time it was read.
|
||||
@@ -111,7 +111,7 @@ func (s *sourceURL) extractFromURL() error {
|
||||
// It parsed but could not be used.
|
||||
return singlePodErr
|
||||
}
|
||||
s.updates <- kubelet.PodUpdate{[]*api.Pod{pod}, kubelet.SET, kubelet.HTTPSource}
|
||||
s.updates <- kubelet.PodUpdate{Pods: []*api.Pod{pod}, Op: kubelet.SET, Source: kubelet.HTTPSource}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ func (s *sourceURL) extractFromURL() error {
|
||||
for i := range podList.Items {
|
||||
pods = append(pods, &podList.Items[i])
|
||||
}
|
||||
s.updates <- kubelet.PodUpdate{pods, kubelet.SET, kubelet.HTTPSource}
|
||||
s.updates <- kubelet.PodUpdate{Pods: pods, Op: kubelet.SET, Source: kubelet.HTTPSource}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@@ -247,7 +247,7 @@ func TestExtractPodsFromHTTP(t *testing.T) {
|
||||
var versionedPods runtime.Object
|
||||
err := testapi.Converter().Convert(&testCase.pods, &versionedPods)
|
||||
if err != nil {
|
||||
t.Fatalf("error in versioning the pods: %s", testCase.desc, err)
|
||||
t.Fatalf("%s: error in versioning the pods: %s", testCase.desc, err)
|
||||
}
|
||||
data, err := testapi.Codec().Encode(versionedPods)
|
||||
if err != nil {
|
||||
|
@@ -38,7 +38,7 @@ func TestEnvVarsToMap(t *testing.T) {
|
||||
varMap := EnvVarsToMap(vars)
|
||||
|
||||
if e, a := len(vars), len(varMap); e != a {
|
||||
t.Error("Unexpected map length; expected: %v, got %v", e, a)
|
||||
t.Errorf("Unexpected map length; expected: %d, got %d", e, a)
|
||||
}
|
||||
|
||||
if a := varMap["foo"]; a != "bar" {
|
||||
|
@@ -269,7 +269,7 @@ func TestPullWithJSONError(t *testing.T) {
|
||||
}
|
||||
err := puller.Pull(test.imageName, []api.Secret{})
|
||||
if err == nil || !strings.Contains(err.Error(), test.expectedError) {
|
||||
t.Errorf("%d: expect error %s, got : %s", i, test.expectedError, err)
|
||||
t.Errorf("%s: expect error %s, got : %s", i, test.expectedError, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
@@ -288,7 +288,7 @@ func (f *FakeDockerClient) CreateExec(opts docker.CreateExecOptions) (*docker.Ex
|
||||
defer f.Unlock()
|
||||
f.execCmd = opts.Cmd
|
||||
f.called = append(f.called, "create_exec")
|
||||
return &docker.Exec{"12345678"}, nil
|
||||
return &docker.Exec{ID: "12345678"}, nil
|
||||
}
|
||||
|
||||
func (f *FakeDockerClient) StartExec(_ string, _ docker.StartExecOptions) error {
|
||||
|
@@ -588,7 +588,7 @@ func (dm *DockerManager) runContainer(
|
||||
if len(containerHostname) > hostnameMaxLen {
|
||||
containerHostname = containerHostname[:hostnameMaxLen]
|
||||
}
|
||||
namespacedName := types.NamespacedName{pod.Namespace, pod.Name}
|
||||
namespacedName := types.NamespacedName{Namespace: pod.Namespace, Name: pod.Name}
|
||||
labels := map[string]string{
|
||||
"io.kubernetes.pod.name": namespacedName.String(),
|
||||
}
|
||||
@@ -1041,7 +1041,7 @@ func (dm *DockerManager) ExecInContainer(containerId string, cmd []string, stdin
|
||||
return err
|
||||
}
|
||||
if !container.State.Running {
|
||||
return fmt.Errorf("container not running (%s)", container)
|
||||
return fmt.Errorf("container not running (%s)", container.ID)
|
||||
}
|
||||
|
||||
return dm.execHandler.ExecInContainer(dm.client, container, cmd, stdin, stdout, stderr, tty)
|
||||
@@ -1086,7 +1086,7 @@ func (dm *DockerManager) PortForward(pod *kubecontainer.Pod, port uint16, stream
|
||||
}
|
||||
|
||||
if !container.State.Running {
|
||||
return fmt.Errorf("container not running (%s)", container)
|
||||
return fmt.Errorf("container not running (%s)", container.ID)
|
||||
}
|
||||
|
||||
containerPid := container.State.Pid
|
||||
@@ -1531,7 +1531,7 @@ func (dm *DockerManager) pullImage(pod *api.Pod, container *api.Container, pullS
|
||||
if err != nil {
|
||||
glog.Errorf("Couldn't make a ref to pod %v, container %v: '%v'", pod.Name, container.Name, err)
|
||||
}
|
||||
spec := kubecontainer.ImageSpec{container.Image}
|
||||
spec := kubecontainer.ImageSpec{Image: container.Image}
|
||||
present, err := dm.IsImagePresent(spec)
|
||||
if err != nil {
|
||||
if ref != nil {
|
||||
|
@@ -487,7 +487,7 @@ func TestKillContainerInPodWithPreStop(t *testing.T) {
|
||||
}
|
||||
podString, err := testapi.Codec().Encode(pod)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v")
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
containers := []docker.APIContainers{
|
||||
{
|
||||
@@ -838,7 +838,7 @@ func TestProbeContainer(t *testing.T) {
|
||||
}
|
||||
result, err := manager.prober.Probe(&api.Pod{}, api.PodStatus{}, test.testContainer, dc.ID, dc.Created)
|
||||
if test.expectError && err == nil {
|
||||
t.Error("[%d] Expected error but no error was returned.", i)
|
||||
t.Errorf("[%d] Expected error but no error was returned.", i)
|
||||
}
|
||||
if !test.expectError && err != nil {
|
||||
t.Errorf("[%d] Didn't expect error but got: %v", i, err)
|
||||
|
@@ -177,7 +177,7 @@ func NewMainKubelet(
|
||||
}
|
||||
cache.NewReflector(listWatch, &api.Service{}, serviceStore, 0).Run()
|
||||
}
|
||||
serviceLister := &cache.StoreToServiceLister{serviceStore}
|
||||
serviceLister := &cache.StoreToServiceLister{Store: serviceStore}
|
||||
|
||||
nodeStore := cache.NewStore(cache.MetaNamespaceKeyFunc)
|
||||
if kubeClient != nil {
|
||||
@@ -194,7 +194,7 @@ func NewMainKubelet(
|
||||
}
|
||||
cache.NewReflector(listWatch, &api.Node{}, nodeStore, 0).Run()
|
||||
}
|
||||
nodeLister := &cache.StoreToNodeLister{nodeStore}
|
||||
nodeLister := &cache.StoreToNodeLister{Store: nodeStore}
|
||||
|
||||
// TODO: get the real minion object of ourself,
|
||||
// and use the real minion name and UID.
|
||||
@@ -1234,7 +1234,7 @@ func (kl *Kubelet) syncPod(pod *api.Pod, mirrorPod *api.Pod, runningPod kubecont
|
||||
}
|
||||
|
||||
podStatus = pod.Status
|
||||
podStatus.StartTime = &util.Time{start}
|
||||
podStatus.StartTime = &util.Time{Time: start}
|
||||
kl.statusManager.SetPodStatus(pod, podStatus)
|
||||
glog.V(3).Infof("Not generating pod status for new pod %q", podFullName)
|
||||
} else {
|
||||
|
@@ -390,7 +390,7 @@ func TestSyncPodsDeletesWhenSourcesAreReady(t *testing.T) {
|
||||
func TestMountExternalVolumes(t *testing.T) {
|
||||
testKubelet := newTestKubelet(t)
|
||||
kubelet := testKubelet.kubelet
|
||||
kubelet.volumePluginMgr.InitPlugins([]volume.VolumePlugin{&volume.FakeVolumePlugin{"fake", nil}}, &volumeHost{kubelet})
|
||||
kubelet.volumePluginMgr.InitPlugins([]volume.VolumePlugin{&volume.FakeVolumePlugin{PluginName: "fake", Host: nil}}, &volumeHost{kubelet})
|
||||
|
||||
pod := api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
@@ -425,7 +425,7 @@ func TestMountExternalVolumes(t *testing.T) {
|
||||
func TestGetPodVolumesFromDisk(t *testing.T) {
|
||||
testKubelet := newTestKubelet(t)
|
||||
kubelet := testKubelet.kubelet
|
||||
plug := &volume.FakeVolumePlugin{"fake", nil}
|
||||
plug := &volume.FakeVolumePlugin{PluginName: "fake", Host: nil}
|
||||
kubelet.volumePluginMgr.InitPlugins([]volume.VolumePlugin{plug}, &volumeHost{kubelet})
|
||||
|
||||
volsOnDisk := []struct {
|
||||
@@ -439,7 +439,7 @@ func TestGetPodVolumesFromDisk(t *testing.T) {
|
||||
|
||||
expectedPaths := []string{}
|
||||
for i := range volsOnDisk {
|
||||
fv := volume.FakeVolume{volsOnDisk[i].podUID, volsOnDisk[i].volName, plug}
|
||||
fv := volume.FakeVolume{PodUID: volsOnDisk[i].podUID, VolName: volsOnDisk[i].volName, Plugin: plug}
|
||||
fv.SetUp()
|
||||
expectedPaths = append(expectedPaths, fv.GetPath())
|
||||
}
|
||||
@@ -3140,7 +3140,7 @@ func TestSyncPodsSetStatusToFailedForPodsThatRunTooLong(t *testing.T) {
|
||||
podFullName := kubecontainer.GetPodFullName(pods[0])
|
||||
status, found := kubelet.statusManager.GetPodStatus(podFullName)
|
||||
if !found {
|
||||
t.Errorf("expected to found status for pod %q", status)
|
||||
t.Errorf("expected to found status for pod %q", podFullName)
|
||||
}
|
||||
if status.Phase != api.PodFailed {
|
||||
t.Fatalf("expected pod status %q, ot %q.", api.PodFailed, status.Phase)
|
||||
@@ -3195,7 +3195,7 @@ func TestSyncPodsDoesNotSetPodsThatDidNotRunTooLongToFailed(t *testing.T) {
|
||||
podFullName := kubecontainer.GetPodFullName(pods[0])
|
||||
status, found := kubelet.statusManager.GetPodStatus(podFullName)
|
||||
if !found {
|
||||
t.Errorf("expected to found status for pod %q", status)
|
||||
t.Errorf("expected to found status for pod %q", podFullName)
|
||||
}
|
||||
if status.Phase == api.PodFailed {
|
||||
t.Fatalf("expected pod status to not be %q", status.Phase)
|
||||
|
@@ -63,7 +63,7 @@ func (ow *realOOMWatcher) Start(ref *api.ObjectReference) error {
|
||||
|
||||
for event := range eventChannel.GetChannel() {
|
||||
glog.V(2).Infof("Got sys oom event from cadvisor: %v", event)
|
||||
ow.recorder.PastEventf(ref, util.Time{event.Timestamp}, systemOOMEvent, "System OOM encountered")
|
||||
ow.recorder.PastEventf(ref, util.Time{Time: event.Timestamp}, systemOOMEvent, "System OOM encountered")
|
||||
}
|
||||
glog.Errorf("Unexpectedly stopped receiving OOM notifications from cAdvisor")
|
||||
}()
|
||||
|
@@ -108,7 +108,7 @@ func (kl *Kubelet) mountExternalVolumes(pod *api.Pod) (kubecontainer.VolumeMap,
|
||||
|
||||
// Try to use a plugin for this volume.
|
||||
internal := volume.NewSpecFromVolume(volSpec)
|
||||
builder, err := kl.newVolumeBuilderFromPlugins(internal, pod, volume.VolumeOptions{rootContext}, kl.mounter)
|
||||
builder, err := kl.newVolumeBuilderFromPlugins(internal, pod, volume.VolumeOptions{RootContext: rootContext}, kl.mounter)
|
||||
if err != nil {
|
||||
glog.Errorf("Could not create volume builder for pod %s: %v", pod.UID, err)
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user