diff --git a/pkg/kubelet/dockershim/libdocker/fake_client.go b/pkg/kubelet/dockershim/libdocker/fake_client.go index eba29931afc..d75728d2e17 100644 --- a/pkg/kubelet/dockershim/libdocker/fake_client.go +++ b/pkg/kubelet/dockershim/libdocker/fake_client.go @@ -23,7 +23,6 @@ import ( "math/rand" "os" "reflect" - "sort" "strconv" "strings" "sync" @@ -270,13 +269,6 @@ func (f *FakeDockerClient) SetFakeContainers(containers []*FakeContainer) { } } -func (f *FakeDockerClient) SetFakeRunningContainers(containers []*FakeContainer) { - for _, c := range containers { - c.Running = true - } - f.SetFakeContainers(containers) -} - func (f *FakeDockerClient) AssertCalls(calls []string) (err error) { f.Lock() defer f.Unlock() @@ -299,82 +291,6 @@ func (f *FakeDockerClient) AssertCallDetails(calls ...CalledDetail) (err error) return } -// idsToNames converts container ids into names. The caller must hold the lock. -func (f *FakeDockerClient) idsToNames(ids []string) ([]string, error) { - names := []string{} - for _, id := range ids { - names = append(names, strings.TrimPrefix(f.ContainerMap[id].Name, dockerNamePrefix)) - } - return names, nil -} - -func (f *FakeDockerClient) AssertCreatedByNameWithOrder(created []string) error { - f.Lock() - defer f.Unlock() - actualCreated, err := f.idsToNames(f.Created) - if err != nil { - return err - } - if !reflect.DeepEqual(created, actualCreated) { - return fmt.Errorf("expected %#v, got %#v", created, actualCreated) - } - return nil -} - -func (f *FakeDockerClient) AssertCreatedByName(created []string) error { - f.Lock() - defer f.Unlock() - - actualCreated, err := f.idsToNames(f.Created) - if err != nil { - return err - } - return sortedStringSlicesEqual(created, actualCreated) -} - -func (f *FakeDockerClient) AssertStoppedByName(stopped []string) error { - f.Lock() - defer f.Unlock() - actualStopped, err := f.idsToNames(f.Stopped) - if err != nil { - return err - } - return sortedStringSlicesEqual(stopped, actualStopped) -} - -func (f *FakeDockerClient) AssertStopped(stopped []string) error { - f.Lock() - defer f.Unlock() - // Copy stopped to avoid modifying it. - actualStopped := append([]string{}, f.Stopped...) - return sortedStringSlicesEqual(stopped, actualStopped) -} - -func (f *FakeDockerClient) AssertImagesPulled(pulled []string) error { - f.Lock() - defer f.Unlock() - // Copy pulled to avoid modifying it. - actualPulled := append([]string{}, f.ImagesPulled...) - return sortedStringSlicesEqual(pulled, actualPulled) -} - -func (f *FakeDockerClient) AssertImagesPulledMsgs(expected []string) error { - f.Lock() - defer f.Unlock() - // Copy pulled to avoid modifying it. - actual := append([]string{}, f.pulled...) - return sortedStringSlicesEqual(expected, actual) -} - -func sortedStringSlicesEqual(expected, actual []string) error { - sort.StringSlice(expected).Sort() - sort.StringSlice(actual).Sort() - if !reflect.DeepEqual(expected, actual) { - return fmt.Errorf("expected %#v, got %#v", expected, actual) - } - return nil -} - func (f *FakeDockerClient) popError(op string) error { if f.Errors == nil { return nil @@ -398,7 +314,6 @@ func (f *FakeDockerClient) ListContainers(options dockertypes.ContainerListOptio if options.All { // Although the container is not sorted, but the container with the same name should be in order, // that is enough for us now. - // TODO(random-liu): Is a fully sorted array needed? containerList = append(containerList, f.ExitedContainerList...) } // Filters containers with id, only support 1 id.