From 354ff6256d47efea92444bc361be58484926ca93 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Wed, 19 Feb 2020 20:49:31 -0800 Subject: [PATCH] improve comments --- pkg/drivers/kic/oci/oci.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/drivers/kic/oci/oci.go b/pkg/drivers/kic/oci/oci.go index 49611fa75..46da8b026 100644 --- a/pkg/drivers/kic/oci/oci.go +++ b/pkg/drivers/kic/oci/oci.go @@ -35,8 +35,7 @@ import ( ) // DeleteAllContainersByLabel deletes all containers that have a specific label -// if contatiners founds will not return an error -// example: docker volume prune -f --filter label=name.minikube.sigs.k8s.io=minikube +// if there are no containers found with the label, it will return nil func DeleteAllContainersByLabel(ociBin string, label string) []error { var deleteErrs []error if ociBin == Docker { @@ -48,6 +47,9 @@ func DeleteAllContainersByLabel(ociBin string, label string) []error { if err != nil { glog.Infof("error listing containers by label %q: %v", label, err) } + if len(cs) == 0 { + return nil + } for _, c := range cs { cmd := exec.Command(ociBin, "rm", "-f", "-v", c) if out, err := cmd.CombinedOutput(); err != nil { @@ -423,8 +425,7 @@ func withPortMappings(portMappings []PortMapping) createOpt { } } -// listContainersByLabel lists all the containres that kic driver created on user's machine using a label -// io.x-k8s.kic.cluster +// listContainersByLabel returns all the container names with a specified label func listContainersByLabel(ociBinary string, label string) ([]string, error) { if err := PointToHostDockerDaemon(); err != nil { return nil, errors.Wrap(err, "point host docker-daemon") -- GitLab