Remove one level of nesting
@@ -55,11 +55,15 @@ func StreamLogs(out io.Writer, client corev1.CoreV1Interface, image string) erro
if err != nil {
return errors.Wrap(err, "getting pods")
}
+
logrus.Infof("Looking for logs to stream for %s", image)
for _, p := range pods.Items {
for _, c := range p.Spec.Containers {
logrus.Debugf("Found container %s with image %s", c.Name, c.Image)
- if c.Image == image {
+ if c.Image != image {
+ continue
+ }
+
logrus.Infof("Trying to stream logs from pod: %s container: %s", p.Name, c.Name)
pods := client.Pods(p.Namespace)
if err := WaitForPodReady(pods, p.Name); err != nil {
@@ -83,7 +87,6 @@ func StreamLogs(out io.Writer, client corev1.CoreV1Interface, image string) erro
return nil
}
}
- }
return fmt.Errorf("Image %s not found", image)
}
