Rename ListOptions to ListContainersOptions

pull/11007/head
Anders F Björklund 2021-04-06 22:39:43 +02:00
parent 22099c8a14
commit db3fd51194
12 changed files with 27 additions and 27 deletions

View File

@ -441,7 +441,7 @@ func (d *Driver) Stop() error {
// even though we can't stop the cotainers inside, we still wanna stop the minikube container itself
klog.Errorf("unable to get container runtime: %v", err)
} else {
containers, err := runtime.ListContainers(cruntime.ListOptions{Namespaces: constants.DefaultNamespaces})
containers, err := runtime.ListContainers(cruntime.ListContainersOptions{Namespaces: constants.DefaultNamespaces})
if err != nil {
klog.Infof("unable list containers : %v", err)
}

View File

@ -152,7 +152,7 @@ func (d *Driver) Kill() error {
}
// First try to gracefully stop containers
containers, err := d.runtime.ListContainers(cruntime.ListOptions{})
containers, err := d.runtime.ListContainers(cruntime.ListContainersOptions{})
if err != nil {
return errors.Wrap(err, "containers")
}
@ -164,7 +164,7 @@ func (d *Driver) Kill() error {
return errors.Wrap(err, "stop")
}
containers, err = d.runtime.ListContainers(cruntime.ListOptions{})
containers, err = d.runtime.ListContainers(cruntime.ListContainersOptions{})
if err != nil {
return errors.Wrap(err, "containers")
}
@ -220,7 +220,7 @@ func (d *Driver) Stop() error {
klog.Warningf("couldn't force stop kubelet. will continue with stop anyways: %v", err)
}
}
containers, err := d.runtime.ListContainers(cruntime.ListOptions{})
containers, err := d.runtime.ListContainers(cruntime.ListContainersOptions{})
if err != nil {
return errors.Wrap(err, "containers")
}

View File

@ -191,7 +191,7 @@ func (d *Driver) Stop() error {
klog.Warningf("couldn't force stop kubelet. will continue with stop anyways: %v", err)
}
}
containers, err := d.runtime.ListContainers(cruntime.ListOptions{})
containers, err := d.runtime.ListContainers(cruntime.ListContainersOptions{})
if err != nil {
return errors.Wrap(err, "containers")
}
@ -219,7 +219,7 @@ func (d *Driver) Kill() error {
}
// First try to gracefully stop containers
containers, err := d.runtime.ListContainers(cruntime.ListOptions{})
containers, err := d.runtime.ListContainers(cruntime.ListContainersOptions{})
if err != nil {
return errors.Wrap(err, "containers")
}
@ -231,7 +231,7 @@ func (d *Driver) Kill() error {
return errors.Wrap(err, "stop")
}
containers, err = d.runtime.ListContainers(cruntime.ListOptions{})
containers, err = d.runtime.ListContainers(cruntime.ListContainersOptions{})
if err != nil {
return errors.Wrap(err, "containers")
}

View File

@ -367,7 +367,7 @@ func (k *Bootstrapper) unpause(cfg config.ClusterConfig) error {
return err
}
ids, err := cr.ListContainers(cruntime.ListOptions{State: cruntime.Paused, Namespaces: []string{"kube-system"}})
ids, err := cr.ListContainers(cruntime.ListContainersOptions{State: cruntime.Paused, Namespaces: []string{"kube-system"}})
if err != nil {
return errors.Wrap(err, "list paused")
}
@ -819,7 +819,7 @@ func (k *Bootstrapper) DeleteCluster(k8s config.KubernetesConfig) error {
klog.Warningf("stop kubelet: %v", err)
}
containers, err := cr.ListContainers(cruntime.ListOptions{Namespaces: []string{"kube-system"}})
containers, err := cr.ListContainers(cruntime.ListContainersOptions{Namespaces: []string{"kube-system"}})
if err != nil {
klog.Warningf("unable to list kube-system containers: %v", err)
}
@ -1023,7 +1023,7 @@ func (k *Bootstrapper) stopKubeSystem(cfg config.ClusterConfig) error {
return errors.Wrap(err, "new cruntime")
}
ids, err := cr.ListContainers(cruntime.ListOptions{Namespaces: []string{"kube-system"}})
ids, err := cr.ListContainers(cruntime.ListContainersOptions{Namespaces: []string{"kube-system"}})
if err != nil {
return errors.Wrap(err, "list")
}

View File

@ -55,7 +55,7 @@ func pause(cr cruntime.Manager, r command.Runner, namespaces []string) ([]string
return ids, errors.Wrap(err, "kubelet stop")
}
ids, err := cr.ListContainers(cruntime.ListOptions{State: cruntime.Running, Namespaces: namespaces})
ids, err := cr.ListContainers(cruntime.ListContainersOptions{State: cruntime.Running, Namespaces: namespaces})
if err != nil {
return ids, errors.Wrap(err, "list running")
}
@ -84,7 +84,7 @@ func Unpause(cr cruntime.Manager, r command.Runner, namespaces []string) ([]stri
// unpause unpauses a Kubernetes cluster
func unpause(cr cruntime.Manager, r command.Runner, namespaces []string) ([]string, error) {
ids, err := cr.ListContainers(cruntime.ListOptions{State: cruntime.Paused, Namespaces: namespaces})
ids, err := cr.ListContainers(cruntime.ListContainersOptions{State: cruntime.Paused, Namespaces: namespaces})
if err != nil {
return ids, errors.Wrap(err, "list paused")
}
@ -105,7 +105,7 @@ func unpause(cr cruntime.Manager, r command.Runner, namespaces []string) ([]stri
}
func CheckIfPaused(cr cruntime.Manager, namespaces []string) (bool, error) {
ids, err := cr.ListContainers(cruntime.ListOptions{State: cruntime.Paused, Namespaces: namespaces})
ids, err := cr.ListContainers(cruntime.ListContainersOptions{State: cruntime.Paused, Namespaces: namespaces})
if err != nil {
return true, errors.Wrap(err, "list paused")
}

View File

@ -288,7 +288,7 @@ func (r *Containerd) KubeletOptions() map[string]string {
}
// ListContainers returns a list of managed by this container runtime
func (r *Containerd) ListContainers(o ListOptions) ([]string, error) {
func (r *Containerd) ListContainers(o ListContainersOptions) ([]string, error) {
return listCRIContainers(r.Runner, containerdNamespaceRoot, o)
}

View File

@ -37,7 +37,7 @@ type container struct {
}
// crictlList returns the output of 'crictl ps' in an efficient manner
func crictlList(cr CommandRunner, root string, o ListOptions) (*command.RunResult, error) {
func crictlList(cr CommandRunner, root string, o ListContainersOptions) (*command.RunResult, error) {
klog.Infof("listing CRI containers in root %s: %+v", root, o)
// Use -a because otherwise paused containers are missed
@ -63,7 +63,7 @@ func crictlList(cr CommandRunner, root string, o ListOptions) (*command.RunResul
}
// listCRIContainers returns a list of containers
func listCRIContainers(cr CommandRunner, root string, o ListOptions) ([]string, error) {
func listCRIContainers(cr CommandRunner, root string, o ListContainersOptions) ([]string, error) {
rr, err := crictlList(cr, root, o)
if err != nil {
return nil, errors.Wrap(err, "crictl list")

View File

@ -213,7 +213,7 @@ func (r *CRIO) KubeletOptions() map[string]string {
}
// ListContainers returns a list of managed by this container runtime
func (r *CRIO) ListContainers(o ListOptions) ([]string, error) {
func (r *CRIO) ListContainers(o ListContainersOptions) ([]string, error) {
return listCRIContainers(r.Runner, "", o)
}

View File

@ -102,8 +102,8 @@ type Manager interface {
// RemoveImage remove image based on name
RemoveImage(string) error
// ListContainers returns a list of managed by this container runtime
ListContainers(ListOptions) ([]string, error)
// ListContainers returns a list of containers managed by this container runtime
ListContainers(ListContainersOptions) ([]string, error)
// KillContainers removes containers based on ID
KillContainers([]string) error
// StopContainers stops containers based on ID
@ -138,8 +138,8 @@ type Config struct {
InsecureRegistry []string
}
// ListOptions are the options to use for listing containers
type ListOptions struct {
// ListContainersOptions are the options to use for listing containers
type ListContainersOptions struct {
// State is the container state to filter by (All, Running, Paused)
State ContainerState
// Name is a name filter

View File

@ -699,7 +699,7 @@ func TestContainerFunctions(t *testing.T) {
}
// Get the list of apiservers
got, err := cr.ListContainers(ListOptions{Name: "apiserver"})
got, err := cr.ListContainers(ListContainersOptions{Name: "apiserver"})
if err != nil {
t.Fatalf("ListContainers: %v", err)
}
@ -712,7 +712,7 @@ func TestContainerFunctions(t *testing.T) {
if err := cr.StopContainers(got); err != nil {
t.Fatalf("stop failed: %v", err)
}
got, err = cr.ListContainers(ListOptions{Name: "apiserver"})
got, err = cr.ListContainers(ListContainersOptions{Name: "apiserver"})
if err != nil {
t.Fatalf("ListContainers: %v", err)
}
@ -722,7 +722,7 @@ func TestContainerFunctions(t *testing.T) {
}
// Get the list of everything else.
got, err = cr.ListContainers(ListOptions{})
got, err = cr.ListContainers(ListContainersOptions{})
if err != nil {
t.Fatalf("ListContainers: %v", err)
}
@ -735,7 +735,7 @@ func TestContainerFunctions(t *testing.T) {
if err := cr.KillContainers(got); err != nil {
t.Errorf("KillContainers: %v", err)
}
got, err = cr.ListContainers(ListOptions{})
got, err = cr.ListContainers(ListContainersOptions{})
if err != nil {
t.Fatalf("ListContainers: %v", err)
}

View File

@ -212,7 +212,7 @@ func (r *Docker) KubeletOptions() map[string]string {
}
// ListContainers returns a list of containers
func (r *Docker) ListContainers(o ListOptions) ([]string, error) {
func (r *Docker) ListContainers(o ListContainersOptions) ([]string, error) {
if r.UseCRI {
return listCRIContainers(r.Runner, "", o)
}

View File

@ -248,7 +248,7 @@ func OutputOffline(lines int) {
func logCommands(r cruntime.Manager, bs bootstrapper.Bootstrapper, cfg config.ClusterConfig, length int, follow bool) map[string]string {
cmds := bs.LogCommands(cfg, bootstrapper.LogOptions{Lines: length, Follow: follow})
for _, pod := range importantPods {
ids, err := r.ListContainers(cruntime.ListOptions{Name: pod})
ids, err := r.ListContainers(cruntime.ListContainersOptions{Name: pod})
if err != nil {
klog.Errorf("Failed to list containers for %q: %v", pod, err)
continue