(ctx context.Context, client kubectl.Client, namespace string, labelSelector string, containerName string, skipContainer FilterContainer, skipInit bool)
| 266 | } |
| 267 | |
| 268 | func byLabelSelector(ctx context.Context, client kubectl.Client, namespace string, labelSelector string, containerName string, skipContainer FilterContainer, skipInit bool) ([]*SelectedPodContainer, error) { |
| 269 | retPods := []*SelectedPodContainer{} |
| 270 | podList, err := client.KubeClient().CoreV1().Pods(namespace).List(ctx, metav1.ListOptions{LabelSelector: labelSelector}) |
| 271 | if err != nil { |
| 272 | return nil, errors.Wrap(err, "list pods") |
| 273 | } |
| 274 | |
| 275 | for _, pod := range podList.Items { |
| 276 | if !skipInit { |
| 277 | for _, container := range pod.Spec.InitContainers { |
| 278 | if skipContainer != nil && skipContainer(&pod, &container) { |
| 279 | continue |
| 280 | } |
| 281 | if containerName != "" && container.Name != containerName { |
| 282 | continue |
| 283 | } |
| 284 | |
| 285 | retPod := pod |
| 286 | retContainer := container |
| 287 | retPods = append(retPods, &SelectedPodContainer{ |
| 288 | Pod: &retPod, |
| 289 | Container: &retContainer, |
| 290 | }) |
| 291 | } |
| 292 | } |
| 293 | for _, container := range pod.Spec.Containers { |
| 294 | if skipContainer != nil && skipContainer(&pod, &container) { |
| 295 | continue |
| 296 | } |
| 297 | if containerName != "" && container.Name != containerName { |
| 298 | continue |
| 299 | } |
| 300 | |
| 301 | retPod := pod |
| 302 | retContainer := container |
| 303 | retPods = append(retPods, &SelectedPodContainer{ |
| 304 | Pod: &retPod, |
| 305 | Container: &retContainer, |
| 306 | }) |
| 307 | } |
| 308 | } |
| 309 | return retPods, nil |
| 310 | } |
| 311 | |
| 312 | func byImageName(ctx context.Context, client kubectl.Client, namespace string, imageSelector []string, containerName string, skipContainer FilterContainer, skipInit bool) ([]*SelectedPodContainer, error) { |
| 313 | retPods := []*SelectedPodContainer{} |
no test coverage detected